Move from teardown to on_exit in test setup