Add support for a custom message (plus tests for the same)

Also has some minor cleanup.