Added tests for all cases with given dates
Refactorizing code