Move test setup into common function
Add tests for cacheFile