Remove duplicate code

I found some code duplication listed on https://codeclimate.com/github/bbatsov/rubocop/issues/categories/duplication that was easy to fix. 

I have also directly added tests for `text_utils.rb`.
An example for `-1` would also be interesting.