split out common code into common_test.py
various changes for unit testing