Rework Latex test for nbconvert Python API

Also, skip it if pandoc is not available
Merge pull request #5865 from takluyver/latex-test-fix

Rework Latex test for nbconvert Python API