Fix for #902: Make the test more robust