GetEmitOutput function and testfiles

also, cache soruceFile at the top.