add tests and fix issues with index