WIP. Massive changes to badges.py, refactoring for OOP and for better exception handling. Improved use of patching in test_badges.py. test_badges.py not yet up-to-date with changes in badges.py.