Unit tests and resulting bugfixes and clarifications. Also separated CommandContext interface from impl.