Fix up a little bit of logic; add test.