Correct exit code when test/run fails

Review 1675 by @larkost