Improve visual diff code

 - Simplify a check for an error condition
 - Add a test case to avoid regressing the same error