fixed bug, changed interface and updated tests in parallel_for