WIP: refactoring, some tets are broken