Add unit tests for Utils.ProtocolBuffers and make implementation of it more robust