Bug fix found writing unit tests