refactorings for backends and lots of tests