Fixes some time-related behavior, adds tests