Remove code duplication in index spec