Added a unit test which triggered the leak fixed by c557ccc.  #3494.