tests for teams page. refactoring, pep8 fixes

Addresses issue #40.