Tests run now well. Many bug fixed in refactored code.