ported unit tests from mercurial