Functional tests some refactoring