minor cache_handler refactor and adding tests