fix hg tests when run in timezone east of UTC

Also other misc tidy-ups.