cache tests refactoring cherry picked from redis branch