Replacement for #51

This supercedes #51 which was no longer cleanly mergable and adds an additional spec test.