Refactoring and some tests upF