Fixed some bugs in ProtocolSocketTest and in ProtocolSocket