Refactoring and added another simple test.
Refactoring and added test of packing/unpacking negotiate cmds.