Make test script report error code properly