Perform batched operations in reverse order when undoing

So that it is opposite to the order of original changes
Add test for slow async undo/redos
Perform async operations sequentially in undo-manager

Before all operations would be run syncronously, which caused
problems when the operation was async
Perform batched async operations sequentially in undo-manager
Add test for async undos outside of batch operations
Merge pull request #1206 from Stuk/undo-manager-async

Undo manager async