indexInArray fix.

Patching back to 2.1.x

Added a unit test as well in core.js