Fix bug and update tests.