Fix for rmi throws error "no such id".

Closes #9056. Also closes #9170. Thanks @coolljt0725 for the start!
Includes integration-cli test, I am not necessarily in love with, but it is necessary evil. :smiling_imp: 
updated, but it's not as pretty ;)