fix parser and add some tests