Refactors SC.UndoManager & Adds unit tests

See https://github.com/sproutcore/sproutcore/pull/1036