Refactored code for easier unit testing and finalized metadata file writing

refactored initialization code to make it easier to unit test, made sure that all the functionality was working (i.e. metadata file writing and id creation), also added new unit test file, and a script to run unit tests easier