Add some tests for message history functions

I decided to write some tests to cover the problems brought up in #72 and #76, since testing things by hand was getting very annoying.