Tidied up the emulator code to include Optional and Preconditions
Re-instated SocketTest to determine failure mode