Refactor the remote_node module

Remove the extra 10 second sleep, which was called even before any
contact with the remote node was attempted. So if node is up, the
response is immediate.

Also make sure that the TCPSocket is closed after check,
preventing the leak of file descriptors.
Merge pull request #801 from bkutil/refactor_remote_node

RFC: Refactor the remote_node module