Silence warnings when testing

Also as a bonus this fixes #6767