Add code to model template for when in main scope

Add test for main scope while not in interactive IPython environment.