Write unit tests for the new messaging system.

Alex and I are about to do some minor refactoring on the messaging
system, and this commit adds a first set of tests for our proposed
architecture.