refactoring testrunner socket port logic
cleanup
Use semaphore so that stop can be released/aquired by different threads