Fixes #1829. Preserve variable scope in the REPL
Add REPL scoping tests
@epidemian typo