Unit tests for DISCL-218 - Serialize and restore sessions.

Also added min and max limits to window dimensions. This prevents oversized windows
from crashing the application (seen with PDFs), or too small windows
from being unreachable.
Yes, I wasn't sure if this could be useful to indicate the reason for introducing these tests. But I can remove it.