add state validation; add more tests