adds new tests and refactors a method