More work on bug #7768.  I added more specs and fixed some bugs.