Added unit tests for the pdfs controller.  Refactoring to support unit tests.