fixes test
adds logging
fixes some obvious errors and adds more tests