Fixed packet size bug. Added tests.