Add unit test for packet writing functions
Finish logic of initial state