A code for stellar binary evolution and its application to the formation of helium white dwarfs