some refactoring with the additionnal tests