CLOUDIFY-1397 minor refactoring, protect against illegal situation by throw illegal state