Adding tests
Refactoring to be more DRY