add unittest and some comments