Rewrite environment.py to use a unified dictionary.

Rather than using a dictionary for list and string variables, use one
dictionary for all of them. Track the fact that there are list and strings
using sets of keys stored next to the unified dictionary.
Add better merge functionality, and a test case for it.