Thanks!  After writing the first version, I also didn't feel great implementing it here and thought it should be a separate helper (both for unit test purposes and for other things to use, too).  I started looking for a place to put it... then discovered that one already existed :-).