Add comms tests

Add some tests for comms and a minor fix to avoid a crash on malformed messages.
-Mark