Add a test for removing redundant undo states
Add missing undoStates null checks
Fix compositing more buffers than there are texture units