Aditional tests and refactoring