Fix tests not to hang on failure