Code style
Fix fold implementation. Add some test cases. Add comments when implementation is wrong.