fixed bugs in rest and test