better structure for test script
move functions to testlib.sh