core: fix m_category:foreach/2 and fold/3.