Bugfix discovered from unittest