A layout resets it's elements when you go to it. This is expected behaviour. The fix is not to do this. You are just testing, so use a different mechanism. Look up the ChromeConsole for an easy way to write debugging text, or use a Layer, which you toggle visible/invisible.