Add full tests for the state machine