Coverage and fix error message leak. Closes #1538, for #1524