Move notify_tests_status `trap` to a better place