Refactoring and cleanup to fix dependency.

test_shims.py is caught up but still need to make app.py catch up.