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
@rhyolight  nope :) 
do it like: 
`
retco= $?
if [ $retco -ne 0 ]; then exit $retco; fi; 
`

otherwise you get $? (=0) from the successful `if` command.