Made the test more robust, avoiding WritePendingExceptions.