I would extract the parsing logic into its own file (with a string only signature) so its easier to test.