Refactor test.sh