added state machine tests, bug fixes