fix bug and add some test