Tested writing metadata.json. Added source_repo addability check
Refactoring