PDF Tests and Fixes

Merge of master and #657