arrangement of visibilitychange tests in a better way