Add test cases for text objects and fixed some bugs related to text objects