Move ambiguity test into `indexOf`.

Closes #390.
Closes #386.