This issue behaves as intended based on the following:
This is correct behavior. You can only rely on the count of visible windows matching what you see on screen. This script does the right thing:
tell application "Safari"
set numberOfVisibleWindows to 0
repeat with aWindow in windows
if aWindow is visible then
set numberOfVisibleWindows to numberOfVisibleWindows + 1
end if
end repeat
say numberOfVisibleWindows
end tell