Fixing test script to return proper exit code