Fixed bug in test_sparse_grid.py and made both cpp and py implementation of indices work