When you calculate estimates, try thinking of an optimistic scenario and a pessimistic one. Let’s say they ask to implement a login functionality using Rails. If I’m healthy, everything is fine at home, I’m not distracted, and I work 6 hours a day, I can finish it in 5 working days. If I get sick, or my kid gets sick, or I’m distracted, or there’s a requirement that adds a lot of complexity that I haven’t paid attention to before starting to work on this project, then I think it would take me up to 18-20 working days to finish it.
So here’s the observation: if your optimistic and pessimistic estimations are less than three times between them (pessimistic = optimistic x 3), then probably you should think more about them.
I would always bill the client by the pessimistic estimation if possible. In every other project I’ve worked since, every estimation multiplied by three usually comes put to be very close to reality.