add state_machine
fix test