improve the test framework a bit

Here's a few commits to hopefully improve the test.sh script.