No parse error on new document xquery main template insert

Also added more robust elapsed time calculation.