Adjust lastIndexOf to match es5 spec

`indexOf` was fine. `lastIndexOf` needed some tinkering. Stole most of the tests of @jdalton's test suite

Fixes #1705