move run_on_exit to a place that can be seen by both application and test helper