reverting some previous refactorings + fixing tests