Always echo output in test mode
Add echo_prompt function
Refactor session state updating
Refactor magictype
Prototype of python mode
Raise RuntimeError if codeblock is unmatched