Use ceil() instead of floor() for midpoint calculation

This allows us to drop the if (start === length) kludge, while ensuring that
text.slice(0, end) is tested, fixing an off-by-one error that occurs when the
loop ends with (end - start) == 1.