some bugs fixed and test for periodic boundary added