re-factor parser

add 95% code coverage