Tests for defer and deferonce

Write test cases to check flow of defer and deferOnce as seen in todo task