Fixing flaky datetime tests
(cherry picked from commit 62b06ad)