Add tests for invertIndex