@mathka fix of to array with test

(i've lost it with last merge because it was not tested)