Json logging

Dried up testing and random refactoring. Tests now run via nosetests.