replaced speedometer driven gear with recommended 40 tooth and still not accurate...

If you have a working Speed-O;
The correct speed-O gear is simple to determine.
The error in speed when converted to a percentage is always the same percentage in tooth count change required.
Example;
If your speed-O is off by 20%, then you will need a toothcount change in the same 20%

Which way to go,bigger or smaller, is indicated by the direction of speed change required; more teeth will slow it down. Less will speed it up.

You say that you had a 23t, I think that might be a typo, and you mighta meant 33t
If that's right then;
and now have a 40t.
That is a change of 33/40=82.5% which points to a speed-O of the same percent. So for it to now read correctly at 60 mph, it must have been reading 60/.825= ~73mph before, with the 33t.

BTW
You can use this same logic on the rear gear ratio. If the 40T turns out to be correct, and you did not change tire sizes,then
the previous ratio must have been a; 3.91 x.825= 3.23s
Logically then, knowing the gear change and the tooth count, you can determine the new gear required from them.
Example
going from 3.23s to 3.91s is 3.91/3.23=1.21 or plus 21%, and from a 33t that would be 33 X1.21=39.93=40t
presto!