Fix some issues regarding %id% replacement in emulation commands and firstInstanceId related errors (see MO-216); add tests to prevent this kind of issues in the features