optimize unittest of state machine