Add clock abstraction instead of embedding datetime.now()

Improve unit tests to compare expected ttl against ttl with delta.