fix unit test bugs