Introduce package level `canSearchInCodeUnits`

And use it to solve bugs/simplify code.
Merge pull request #1517 from monarchdodra/fitsInCodeUnit

Fix bugs using `fitsInCodeUnit`