improved mocked socket
tests: reconnect

also, keep writing until error, and reconnect on writing error,
regardless of whether the socket thinks it's still connected