Fixing n+1 inefficiency and updating tests