added docs to state.rs and more tests