Fixes #1416: Plugin command doesn't work

This is an attempt to fix an issue with `plugin` command not working. The issue is described in #1416.

I would love to add some tests, but I need an advise on where to put them.