Fix #777, improve tests, add cb_each