Implemented open-pdf support.

Presently the spec only tests for correct handling of errors. Do not really have idea what to test in case of success.
Simplify code