Again more restructuring and tests