Support setting global visibility
Added more tests