How to test state machine