INT-2903 Fix Timing Problem in TCP Timeout Tests

Use latches and the new CLOSE event instead of arbitrary waits for
sockets to close.

Factor out common test code into setup methods.