Refactor visual highlight tests.
Fix nested and empty visual highlights causes LaTeX errors.