Added tests for timer, and refined implementation