accumulate algorithm and tests, flatten_view tweaks