Handle negative endsWith position properly

Fixes #168