Functional implementation of giant refactoring
Fix unit tests for giant refactoring