PM: reset variables efficiently between page loads and link clicks. + fixed tests