Fix folds

Fix #648
Add tests for folds on longer arrays
Merge pull request #649 from Xashili/patch-1

Fix folds