Rename TermCache to TermIndex.

Includes minor restructuring of test cases and factory.

Change-Id: I8d8c4b0430e42ac3acdf95d14cc966640dd4e885
Merge "Rename TermCache to TermIndex."