Interesting analysis, but yup, that's what tests are for! If you've got a sporadically failing test somewhere, that's probably sign of a bug.
This particular bug is also a strong argument for using more advanced type systems, even if you have good test coverage.
Yes, it's a great pity that the compiler didn't say "You're multiplying a time.Duration by a time.Duration and expecting it to be a time.Duration".
In this case, that's not what's going on, though. It's multiplying time by unitless scaling factor, which doesn't present the same problem. However, there's a few ways you can get at the issue with the help of the language, you just have to distinguish between the different units you might be using to represent time - this doesn't really take an advanced type system: the example of having a .milliseconds method is along these lines.
struct duration { int in_nanoseconds; };
struct duration seconds_duration (int in_seconds) {
struct duration dt;
dt.in_nanoseconds = in_seconds * 1000000000;
return dt;
}
/*TODO: milliseconds_duration(), microseconds_duration(), etc */