Add more thorough integration test. Fix caching issues.