fixed bugs in testing code