Extract helper in spec to set up refactor

This will make it easier to refactor the implementation to use
highlight decorations without changing the tests