Refactoring on index test