de-duplicate code in test.sh