Add stats calls to communityview.

- Untested.  Circular import problem exists.
- Add license header to stats.py and testStats.py.
- Minor mods to stats.py.
Fix test code's handling of new stats thread.

- Update terminateTestRun() and waitForThreads() in TestCommunityView
to correctly handle existence of new stats thread.
- Create utils.py and move several utility functions from
communityview.py to utils.py.
- Add thread re-naming functions to utils.py and use for stats thread.
- Improve the way localsettings vars are replaced by testsettings vars
in TestCommunityView.py and testStats.py.
- Misc bug fixes in test code.
- Misc comment fixes.