Fix Main.test bug. extract singleton_decorator. Add documentation to base. Fix various pep8