Add filename extension to output/cached files

Should help with mime/content types.
Also add simple test that cache key does not change