Refactor w/ tests