Refactor truncateTextToLength out of Label and into Utils.

Add better unit testing.
Change API so it no longer modifies the element as a side-effect, but instead
takes the text, element, and length, measures the text in the element, returns
shorter text, and returns the textElement to its original state.

I think this is a better API so that it can be called multiple times without
getting into weird states, and its easier to reason about functions without
side effects.