Add unit test for text message.
optimize code.