Fix a bug found in tests