Refactoring packet_codec serialization routines and merging read and write tests into one unit