tests working, misc fixes

all tests succeeding at running and outputting to DB. Minor CS changes and bug fixes