Add unit test

Test fails on master at c61f65ab804a795c848d2ac6cd1db9c1d5d0d891,
passes in this commit.