Refactor testUndo().