add unittest and some fix