Fix exception in commands that contain capital letters.

Fixes #1561. Removes an erroneous call to .lower() and adds regression tests.