Fix bug shown by tests