However, whilst I can happily change to UNIT_FOOT, UNIT_METER even UNIT_US_NAUTICAL_MILE I can't seem to get UNIT_YARD to work.
Looking at the DistanceParameters - it appears to store these as valies - so UNIT_METER is returned in the console as 9001. However UNIT_YARD returns UNDEFINED - surely that is a valid unit?
Check out the server REST API help for info on possible values. Starting from the buffer help, you can get to two pages that list possible units from the description for the "unit" parameter: