fix thread tests and add wait for  child process