add message_builder tests and fix error handling logic