Add tests for MessageCostForm and fix bugs revealed.