Text widget refactor and tests

@ppong @bigsley