fix bug and set up test