rewrite Transaction/StateMachine yet again, tests are passing