properly exiting with test_result code