Make sure the test won't fail under Valgrind
(cherry picked from commit 90e51f4efbba917ba9d7f6f11f20e8ac8e6af3fa)