Refactored getNextMillis() a tiny bit, so that it's easier to test.