Add StateMachine and tests. Use Sinon for better event tests