Fixes #6848,BZ1124547 - Checking content view environments

Checking that a content view is in the environment before trying to remove it
from the environment.
Merge pull request #4507 from daviddavis/temp/20140730151145

Fixes #6848,BZ1124547 - Checking content view environments