Fix root logic and adapt tests
Version 2