Added tests for Idempotent sagas. Fix some bugs raised by the tests.