refactor SocketThread to be more unit test friendly