Fix cache tests not to leak prefs.