Fix for WSCOMMONS-142 - Inefficient code in TextImpl and OMTextImpl. Took the opportunity to remove duplicate code