fix parser semantics; add factorial test case which exposed the bug