many fixes
fix state
improve test coverage