Fixed a typo in the last PR. Also added a unit test.