use POSIX syntax for shell function definition in run_test

my sh in ubuntu does not support function keyword