Add unit test for readPacket (client mode)

recv is updated to correct a bug when transitioning across packets
when in blocking mode, as well as to have more consistent code.

Change-Id: Id1c0e8178e6d79d1bf7972c9dfe18673fd6a033c