Correct last measure date checking and add more time-based unit tests.