Fix a bug when executing a new ScriptedCommand with prefix in the connection

Unit test is provided.