Code:
ns:UpdateAuraIcon = function(element, button)
Isn't valid Lua, so that's why it didn't work. It should be:
Code:
ns.UpdateAuraIcon = function(element, button)
Notice the dot instead of semi-colon
Your new function definition works because:
Code:
function ns:UpdateAuraIcon(button)
Is the same as:
Code:
function ns.UpdateAuraIcon(ns, button)