Implemented module cast logic + some tests + fixed mock compiler to work in chain