Refactoring Test to remove all duplicated code