add test reduce
add begin error handling (+ fix reduce)