add unittest for i.py and fix bugs