Fix a bug in calculation of firstBillingCycleDay.

Add unit tests of that method to verify through various case scenarios that it computes the right date.