Fixes a bug with setting isModal to YES on a PanelPane in transition out. +unit tests

Previously, the panel would append — and then never remove — its ModalPane if isModal was set to YES during transition out. The fix was to check viewState instead of isVisibleInWindow.

Added a unit test for this, and the rest of ModalPane's expected behavior while I was at it.