fix tests
array_reduce to foreach

error handling is too poor ..