Added error checking and tests
Add tidy config
Test fixes and tidying
Fixed metadat loading and test