Fix to close a tcp socket properly AND set explicit timeout to all test cases to make executing tests stable