fix bugs in testing