add unit tests for folding