Fixes and error detection for runtests.sh