State machine works in tests
More refinements