CLOUDIFY-1397 some refactoring. added java doc and better semantics for rest client
CLOUDIFY-1397 extract cleanup to seperate method to avoid code duplication