Move parsing out so that it is testable