Add tests for RemoteViaSocket shut-downs, restarts, etc.

and fix some issues