Add log test, fix some bugs