Fix send_message command and add some tests.

It looks like the send_message command is a bit broken since #270 landed, but we didn't notice because test coverage is poor.