Qae1030 pdf generation corrects

* Better handling of conditions
* Refactoring
* Rspecs fixing