This is really a speculative fix, as I could not reproduce the described issue. It appears
that the most likely explanation is an image which failed to import fully, so I modified
the code slightly to clean up better in that case.
I get 3 failing Cucumber tests with or without this patch.