Extract mock autoloader

This fixes the issue described in #403