Add several test cases for cache updater, and make several adjustments to cache updater itself to fix bugs in edge cases