Applied a patch from Rob to fix RT-97598, and added a test