Add sinon dependency.

Testing timers is much easier with sinon.
Add tests and fixes for reconnection logic.