Add unit tests.

I added a test that uses setTimeout but I also kept the old one, because it does test that the time the function returns is really the current one after all.