fix all tests and a little cleaning
some inlining and renaming