fix some issues with caching and add resource caching tests