Fixing issue #392, adding tests.

See issue #392.