two fixes for run_test script

* use POSIX syntax for shell function definition in run_test
    my sh in ubuntu does not support function keyword
* make sure deadloop test is killed by pkill