make run_examples.sh and run_tests.sh more robust