Attempt to fix most of the unittests + removing old legacy code.