refactor (do not convert $value to array but rather typecast), fix tests