Returning failure exit code for test scripts.

Tests run within scripts were failing silently. I added bash logic after test
runs to check previous exit status and exit the script with a failure code if
the test commands failed.

Fixes #1293
Are you sure the `if` command returns an exit code? I tested this in a local bash script and it worked as expected.