BUG: indexing bug

And add test