improve state implementation + increase test coverage