refactoring of output + functional tests