We isolated the parse code and we added some tests for it.

Parse code now has its own file.

We also added an exception for  sudden end of file during parsing. And
we made the parser more robust, while adding more tests.