Issue #8 #16. Optimize and re-factor text test case.

Incorporated review comments and optimized. Changes are verified.