added tests for invalid undo operation
added some comments