Fixed bug with testVisibility function