Improve base parse functions, add tests.