fix aggs not updating in cache.
add unit tests.