GetEmitOutput function and testfiles

This is incorrect check.. You could have specified --out but if your file is module it wouldn't go into single file. You should checkout emitter's shouldEmitToOwnFile instead