Add some more sanity checks in run-tests.sh, and refactor that part of the script
a little.

No issue #