Added for_each_safe-macros for lists and a corresponding test