You're not going to be able to check against "5 meters in coordinates", because the difference in lat/lon values for points 5m apart is going to vary based on position on the surface of the sphere.
You can try testing your output against values from an existing script. It would not be very usual for lats and lons to be stored in radians, I would definitely check that.
There doesn't seem to be anything amiss with the calculations, but you probably mean to:
return km
at the end of the haversine
function, so that print haversine(...)
actual does something meaningful.