Fixing bug where doing max -> min -> restore does not result in a restored window. Adding a test for this case.