improved test for non-zero exit code