Fix window message error from !45
!45 (merged) could modify the global tl
and th
parameters by flipping them. If a search returned these remained flipped.
The solution is to use temporary parameters every search result. Also included a unittest to capture this situation for the future.