Improve clean_cache method. Add a test.