This seems to be wrong (you are returning a list inside another list). It could be written as:

    erl.update_attributes List.keyreplace(&1, attr, 1, { attr, avalue(value) ++ found })