Fixed bugs in Index + added Index test
fix Index bugs