Fix getVisibleParent when no parent is visible. Add tests for getVisibleParent. Fixes #265