fix error throwing and added test

parse error was not throwing, so I made it throw (by returning error) and added a test for it.