Cleanup a test and make it a bit more robust.