Capitalize mode enum value
Add one system-mode testing case.

Fix bunch of minior bugs exposed by this testing case.