add exit codes and fix test script