refactoring to reduce entanglement
fixes test and cleanup
adds logging
starting to add integration tests