Javadoc improvements.
Fix stripping trailing whitespace from a whitespace-only string.
Thoroughly test util for special case scenarios.