more fsm code and a testing file