Tests and fixes for TopAndTailCache.