Fix #1084 and #1085 (miscellaneous issues with --modules=instantiate)

The following commits close the bugs #1084 and #1085, and add regression tests.
long line. We limit the length to 80 columns.