Refactor parse-entry function to make it more readable.

Add a handful more tests.