code cleanup. Restructured tests.py to use the unittest module.