completion transition refactoring, event generation refactoring and support for deferrable events
improve testing framework to use waiting with time for state change