added undo functionality to state class with tests