added undo funtionality and tests for this accordingly