Refactor some functionality out of gen_tile.cpp

Move metatile handling and tile cache expiry out of gen_tile.cpp into
seperate files for reuse and cleaner structure.
Add some tests for the default file storage backend