fix bug and update tests