Refactored machines part including cli

I have also added specs to prevent any bug in the future. The ability to rename a node through the cli have been added too. **Fix for bnc#826803**