Moving anonymous event handler into a method so that the event, and thus the process object, stay alive while the test is running.

fixes #35