separated out parsing code, improved tester