Moved socket.io to a factory to improve testing