added test for CacheWriter only creates one query
fixed CacheManager listener bug