Many changes and refactoring to please pylint; 'make test' added