add state machine and add task state change test