fix regressions and use timecop to fix time in tests. Thanks Dan and Hans!