test coverage for onleave_state_