Add unit tests.

Add some setTimeout to the test maybe :)