Fix unit tests to exit with the correct return code