moved most main code to run so I can test it, then added a test