added checks to undo functionality on state class along with tests