Move parsing code to buffer ns, with tests [fixes #6]