WIP #22, further  fixes, decoupling and more tests