From aa0161264c67d7802e79492b05aff88533d79d20 Mon Sep 17 00:00:00 2001
From: Marius Gavrilescu <marius@ieval.ro>
Date: Fri, 26 Dec 2014 13:37:55 +0200
Subject: [PATCH] Refactor tests (first pass)

---
 lib/HTML/Element/Library.pm                   |   6 +-
 t/00system.t                                  |  51 ++-----
 t/HTML-Element-Library.t                      |  17 ---
 t/content_handler.t                           |  44 ++----
 t/crunch.t                                    |  29 +---
 t/defmap.t                                    |  36 +----
 t/dual_iter.t                                 |  70 +++------
 t/fillinform.t                                |  29 +---
 t/hashmap.t                                   |  48 ++-----
 t/highlander.t                                |  50 +++----
 t/highlander2.t                               |  72 ++++------
 t/html/{crunch => }/crunch.exp                |   0
 t/html/{crunch/crunch.initial => crunch.html} |   0
 t/html/{defmap => }/defmap.exp                |   0
 t/html/{defmap/defmap.initial => defmap.html} |   0
 t/html/dual_iter.exp                          |  25 ++--
 t/html/{fillinform => }/fillinform.exp        |   9 +-
 .../fillinform.initial => fillinform.html}    |   0
 t/html/{same_as/same_as.exp => hashmap.exp}   |   0
 .../{same_as/same_as.initial => hashmap.html} |   0
 t/html/highlander-15.exp                      |   7 +-
 t/html/highlander-5.exp                       |   7 +-
 t/html/highlander-50.exp                      |   7 +-
 t/html/highlander2-15.exp                     |   7 +-
 t/html/highlander2-27.exp                     |   7 +-
 t/html/highlander2-5.exp                      |   7 +-
 t/html/highlander2-passover.exp               |   7 +-
 t/html/iter.exp                               |   8 +-
 t/html/iter.html                              |   4 +-
 t/html/iter2.exp                              |   8 +-
 t/html/iter2.html                             |   2 +
 t/html/same_as.html                           |  16 ---
 t/html/table-alt.exp                          |   5 -
 t/html/table.exp                              |   5 -
 t/html/table2-tr_ld-coderef.html              |  78 ----------
 t/html/table2-tr_ld-default.html              |  80 -----------
 t/html/table2-tr_ld_coderef.exp               | 134 ------------------
 t/iter.t                                      |  26 +---
 t/iter2.t                                     |  68 ++++-----
 t/lib.pm                                      |  36 +++++
 t/newchild.t                                  |  55 +------
 t/passover.t                                  |  36 +----
 t/position.t                                  |  24 +---
 t/prune.t                                     |  31 +---
 t/replace_content.t                           |  40 ++----
 t/set_child_content.t                         |  44 ++----
 t/sibdex.t                                    |  43 ++----
 t/siblings.t                                  |  51 ++-----
 t/table-alt.t                                 |  70 +++------
 t/table.t                                     |  70 +++------
 t/table2-table_ld.t                           |  60 +++-----
 t/table2-tr_ld.t                              |  96 +++++--------
 t/table2.t                                    |  70 ++++-----
 t/unroll_select.t                             |  38 ++---
 t/wrap_content.t                              |  48 ++-----
 55 files changed, 444 insertions(+), 1337 deletions(-)
 delete mode 100644 t/HTML-Element-Library.t
 rename t/html/{crunch => }/crunch.exp (100%)
 rename t/html/{crunch/crunch.initial => crunch.html} (100%)
 rename t/html/{defmap => }/defmap.exp (100%)
 rename t/html/{defmap/defmap.initial => defmap.html} (100%)
 rename t/html/{fillinform => }/fillinform.exp (88%)
 rename t/html/{fillinform/fillinform.initial => fillinform.html} (100%)
 rename t/html/{same_as/same_as.exp => hashmap.exp} (100%)
 rename t/html/{same_as/same_as.initial => hashmap.html} (100%)
 delete mode 100644 t/html/same_as.html
 delete mode 100644 t/html/table2-tr_ld-coderef.html
 delete mode 100644 t/html/table2-tr_ld-default.html
 delete mode 100644 t/html/table2-tr_ld_coderef.exp
 create mode 100644 t/lib.pm

diff --git a/lib/HTML/Element/Library.pm b/lib/HTML/Element/Library.pm
index 5336eef..553fb0c 100644
--- a/lib/HTML/Element/Library.pm
+++ b/lib/HTML/Element/Library.pm
@@ -301,13 +301,13 @@ sub HTML::Element::iter2 { ## no critic (RequireArgUnpacking)
 		my $item_data  = $p{item_data}->($p{wrapper_data});
 		last unless defined $item_data;
 
-		warn Dumper('item_data', $item_data);
+		warn Dumper('item_data', $item_data) if $p{debug};
 
 		my $item_elems = [ map { $_->clone } @{$_item_elems} ] ;
 
 		if ($p{debug}) {
 			for (@{$item_elems}) {
-				warn 'ITEM_ELEMS ', $_->as_HTML;
+				warn 'ITEM_ELEMS ', $_->as_HTML if $p{debug};
 			}
 		}
 
@@ -315,7 +315,7 @@ sub HTML::Element::iter2 { ## no critic (RequireArgUnpacking)
 
 		if ($p{debug}) {
 			for (@{$new_item_elems}) {
-				warn 'NEWITEM_ELEMS ', $_->as_HTML;
+				warn 'NEWITEM_ELEMS ', $_->as_HTML if $p{debug};
 			}
 		}
 
diff --git a/t/00system.t b/t/00system.t
index 10066ce..4801fe4 100644
--- a/t/00system.t
+++ b/t/00system.t
@@ -1,46 +1,13 @@
-# Welcome to a -*- perl -*- test script
+#!/usr/bin/perl
 use strict;
-use Test::More qw(no_plan);
+use warnings;
 
-sub req_ver {
-  my $string = shift;
-  my $eval = "#Using $string version v\$${string}::VERSION\n";
-  my $eval2 = sprintf 'warn "%s"', $eval;
-  require_ok($string);
-  eval  $eval2 ;
-}
+use Test::More tests => 1;
 
-my @module = 
-  qw(
-     Array::Group 
-     File::Slurp
-
-     HTML::PrettyPrinter 
-     HTML::Tree 
-     HTML::Element
-     HTML::Parser 
-     HTML::Entities 
-     HTML::Tagset 
-
-     List::Rotation::Cycle
-     List::MoreUtils
-
-     Params::Validate
-
-     Scalar::Listify
-    ) ;
-
-req_ver($_) for @module;
-
-warn "# Running under perl version $] for $^O",
-  (chr(65) eq 'A') ? "\n" : " in a non-ASCII world\n";
-warn "# Win32::BuildNumber ", &Win32::BuildNumber(), "\n"
-  if defined(&Win32::BuildNumber) and defined &Win32::BuildNumber();
-warn "# MacPerl verison $MacPerl::Version\n"
-  if defined $MacPerl::Version;
-warn sprintf
-  "# Current time local: %s\n# Current time GMT:   %s\n",
-  scalar(localtime($^T)), scalar(gmtime($^T));
-  
-ok 1;
+diag "Running under perl version $] for $^O",  (chr(65) eq 'A') ? "\n" : " in a non-ASCII world\n";
+diag "Win32::BuildNumber ", &Win32::BuildNumber(), "\n" if defined(&Win32::BuildNumber) and defined &Win32::BuildNumber();
+diag "MacPerl verison $MacPerl::Version\n" if defined $MacPerl::Version;
+diag sprintf "Current time local: %s\n", scalar localtime;
+diag sprintf "Current time GMT:   %s\n", scalar gmtime;
 
+pass;
diff --git a/t/HTML-Element-Library.t b/t/HTML-Element-Library.t
deleted file mode 100644
index 83f9e44..0000000
--- a/t/HTML-Element-Library.t
+++ /dev/null
@@ -1,17 +0,0 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl HTML-Element-Library.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test;
-BEGIN { plan tests => 1 };
-use HTML::Element::Library;
-ok(1); # If we made it this far, we're ok.
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-
diff --git a/t/content_handler.t b/t/content_handler.t
index 8264d70..5a2b203 100644
--- a/t/content_handler.t
+++ b/t/content_handler.t
@@ -1,33 +1,15 @@
-use strict;
-use Test::More qw(no_plan);
+#!/usr/bin/perl
+use t::lib tests => 1;
+
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', 'um, p < 4!', {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body', {id => 'corpus'},
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 'um, p < 4!', {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
-
-
-#$t1->look_down('_tag' => 'body')->replace_content('all gone!');
 $t1->content_handler(corpus => 'all gone!');
-is( $t1->as_HTML, '<html><head><title>I like stuff!</title></head><body id="corpus" lang="en-JP">all gone!</body></html>', "replaced all of body");
-
-
+isxml $t1, \'<html><head><title>I like stuff!</title></head><body id="corpus" lang="en-JP">all gone!</body></html>', 'content_handler';
diff --git a/t/crunch.t b/t/crunch.t
index 627ef2a..241cc3f 100644
--- a/t/crunch.t
+++ b/t/crunch.t
@@ -1,25 +1,6 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;use warnings;
+#!/usr/bin/perl
+use t::lib tests => 1;
 
-use File::Slurp qw/read_file/;
-use Test::More;
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub tage {
-
-  my $root = "t/html/crunch/crunch";
-
-  my $tree = HTML::TreeBuilder->new_from_file("$root.initial")->guts;
-
-  $tree->crunch(look_down => [ class => 'imageElement' ], leave => 1);
-
-  is_xml $tree->as_XML, scalar read_file("$root.exp"), 'XML for crunch';
-}
-
-
-tage();
-
-done_testing;
+my $tree = mktree 't/html/crunch.html';
+$tree->crunch(look_down => [ class => 'imageElement' ], leave => 1);
+isxml $tree, 't/html/crunch.exp', 'crunch';
diff --git a/t/defmap.t b/t/defmap.t
index 26eeeed..880b998 100644
--- a/t/defmap.t
+++ b/t/defmap.t
@@ -1,32 +1,6 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;use warnings;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-use Test::XML;
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-
-sub tage {
-
-  my $root = "t/html/defmap/defmap";
-
-  my $tree = HTML::TreeBuilder->new_from_file("$root.initial")->guts;
-
-  #warn "TREE: $tree" . $tree->as_HTML;
-
-  my %data = (pause => 'arsenal rules');
-
-  $tree->defmap(smap => \%data, 1);
-
-  my $g = $tree->as_XML;
-  my $e = File::Slurp::read_file("$root.exp");
-  warn "generated:$g:\nexpected:$e:";
-
-  is_xml ($g, $e, "XML for defmap");
-}
-
-
-tage();
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $tree = mktree 't/html/defmap.html';
+$tree->defmap(smap => {pause => 'arsenal rules'}, $ENV{TEST_VERBOSE});
+isxml $tree, 't/html/defmap.exp', 'defmap';
diff --git a/t/dual_iter.t b/t/dual_iter.t
index dbcfb28..2c93fd4 100644
--- a/t/dual_iter.t
+++ b/t/dual_iter.t
@@ -1,51 +1,25 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-# this is a simpler call to iter2()
-
-my $root = 't/html/dual_iter';
-
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-my $dl = $tree->look_down(id => 'service_plan');
-
-
-my @items = (
-  ['the pros' => 'never have to worry about service again'],
-  ['the cons' => 'upfront extra charge on purchase'],
-  ['our choice' => 'go with the extended service plan']
- );
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $tree = mktree 't/html/dual_iter.html';
 
 $tree->iter2(
-
-  wrapper_data => \@items,
-
-  wrapper_proc => sub {
-    my ($container) = @_;
-
-    # only keep the last 2 dts and dds
-    my @content_list = $container->content_list;
-    $container->splice_content(0, @content_list - 2); 
-  },
-
-
-  splice       => sub {
-    my ($container, @item_elems) = @_;
-    $container->unshift_content(@item_elems);
-  },
-
-  debug        => 1,
-
- );
-
-
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 
-      "XML for generated li");
+	wrapper_data => [
+		['the pros' => 'never have to worry about service again'],
+		['the cons' => 'upfront extra charge on purchase'],
+		['our choice' => 'go with the extended service plan']
+	],
+	wrapper_proc => sub {
+		my ($container) = @_;
+		# only keep the last 2 dts and dds
+		my @content_list = $container->content_list;
+		$container->splice_content(0, @content_list - 2);
+	},
+	splice       => sub {
+		my ($container, @item_elems) = @_;
+		$container->unshift_content(@item_elems);
+	},
+	debug        => $ENV{TEST_VERBOSE},
+);
+
+isxml $tree, 't/html/dual_iter.exp', 'dual_iter';
diff --git a/t/fillinform.t b/t/fillinform.t
index d989f4e..1d88b2a 100644
--- a/t/fillinform.t
+++ b/t/fillinform.t
@@ -1,26 +1,5 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;use warnings;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub tage {
-
-  my $root = "t/html/fillinform/fillinform";
-
-  my $tree = HTML::TreeBuilder->new_from_file("$root.initial")->guts;
-
-  my %data = (state => 'catatonic');
-
-  my $new_tree = HTML::TreeBuilder->new_from_content( $tree->fillinform(\%data) ) ;
-
-  is_xml ($new_tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "HTML for fillinform");
-}
-
-
-tage();
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $tree = mktree 't/html/fillinform.html';
+isxml \($tree->fillinform({state => 'catatonic'})), 't/html/fillinform.exp', 'fillinform';
diff --git a/t/hashmap.t b/t/hashmap.t
index 9ed2864..ed81f06 100644
--- a/t/hashmap.t
+++ b/t/hashmap.t
@@ -1,38 +1,10 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub replace_age { 
-  my $branch = shift;
-  my $age = shift;
-  $branch->look_down(id => 'age')->replace_content($age);
-}
-
-
-sub tage {
-
-  my $root = "t/html/same_as/same_as";
-
-  my $tree = HTML::TreeBuilder->new_from_file("$root.initial");
-
-  #warn "TREE: $tree" . $tree->as_HTML;
-
-  my %data = (people_id => 888, phone => '444-4444', email => 'm@xml.com');
-
-  $tree->hash_map
-    (hash    => \%data, 
-     to_attr => 'sid', 
-     excluding => [ 'email' ]
-    );
-
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "XML for same_as");
-}
-
-
-tage();
+#!/usr/bin/perl
+use t::lib tests => 1;
+
+my $tree = mktree 't/html/hashmap.html';
+$tree->hash_map(
+	hash      => {people_id => 888, phone => '444-4444', email => 'm@xml.com'},
+	to_attr   => 'sid',
+	excluding => ['email']
+);
+isxml $tree, 't/html/hashmap.exp', 'hash_map';
diff --git a/t/highlander.t b/t/highlander.t
index e9f754c..c224988 100644
--- a/t/highlander.t
+++ b/t/highlander.t
@@ -1,33 +1,21 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub tage {
-  my $age = shift;
-  my $tree = HTML::TreeBuilder->new_from_file('t/html/highlander.html');
-
-
-  $tree->highlander
-    (age_dialog =>
-     [
-      under10 => sub { $_[0] < 10} , 
-      under18 => sub { $_[0] < 18} ,
-      welcome => sub { 1 }
-     ],
-     $age
-    );
-
-  my $root = "t/html/highlander-$age";
-
-  local $_; # XML::Parser does not like read-only $_ (RT #101129)
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "XML for $age");
+#!/usr/bin/perl
+use t::lib tests => 3;
+
+sub test {
+	my $age = shift;
+	my $tree = mktree 't/html/highlander.html';
+
+	$tree->highlander(
+		age_dialog => [
+			under10 => sub { $_[0] < 10 },
+			under18 => sub { $_[0] < 18 },
+			welcome => sub { 1 }
+		],
+		$age
+	);
+
+	local $_; # XML::Parser does not like read-only $_ (RT #101129)
+	isxml $tree, "t/html/highlander-$age.exp", "highlander for $age";
 }
 
-
-tage($_) for qw(5 15 50);
+test $_ for qw(5 15 50);
diff --git a/t/highlander2.t b/t/highlander2.t
index c145b68..dd8252d 100644
--- a/t/highlander2.t
+++ b/t/highlander2.t
@@ -1,48 +1,34 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
+#!/usr/bin/perl
+use t::lib tests => 3;
 
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub replace_age { 
-  my $branch = shift;
-  my $age = shift;
-  $branch->look_down(id => 'age')->replace_content($age);
+sub replace_age {
+	my ($branch, $age) = @_;
+	$branch->look_down(id => 'age')->replace_content($age);
 }
 
-
-sub tage {
-  my $age = shift;
-  my $tree = HTML::TreeBuilder->new_from_file('t/html/highlander2.html');
-  my $if_then = $tree->look_down(id => 'age_dialog');
-
-  $if_then->highlander2(
-    cond => [
-      under10 => [
-	sub { $_[0] < 10} , 
-	\&replace_age
-       ],
-      under18 => [
-	sub { $_[0] < 18} ,
-	\&replace_age
-       ],
-      welcome => [
-	sub { 1 },
-	\&replace_age
-       ]
-     ],
-    cond_arg => [ $age ]
-		       );
-
-  my $root = "t/html/highlander2-$age";
-
-  local $_; # XML::Parser does not like read-only $_ (RT #101129)
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "HTML for $age");
+sub test {
+	my $age = shift;
+	my $tree = mktree 't/html/highlander2.html';
+	my $if_then = $tree->look_down(id => 'age_dialog')->highlander2(
+		cond => [
+			under10 => [
+				sub { $_[0] < 10 },
+				\&replace_age
+			],
+			under18 => [
+				sub { $_[0] < 18 },
+				\&replace_age
+			],
+			welcome => [
+				sub { 1 },
+				\&replace_age
+			]
+		],
+		cond_arg => [ $age ]
+	);
+
+	local $_; # XML::Parser does not like read-only $_ (RT #101129)
+	isxml ($tree, "t/html/highlander2-$age.exp", "highlander2 for age $age");
 }
 
-
-tage($_) for qw(5 15 27);
+test $_ for qw(5 15 27);
diff --git a/t/html/crunch/crunch.exp b/t/html/crunch.exp
similarity index 100%
rename from t/html/crunch/crunch.exp
rename to t/html/crunch.exp
diff --git a/t/html/crunch/crunch.initial b/t/html/crunch.html
similarity index 100%
rename from t/html/crunch/crunch.initial
rename to t/html/crunch.html
diff --git a/t/html/defmap/defmap.exp b/t/html/defmap.exp
similarity index 100%
rename from t/html/defmap/defmap.exp
rename to t/html/defmap.exp
diff --git a/t/html/defmap/defmap.initial b/t/html/defmap.html
similarity index 100%
rename from t/html/defmap/defmap.initial
rename to t/html/defmap.html
diff --git a/t/html/dual_iter.exp b/t/html/dual_iter.exp
index 64c6c8f..c2e9d44 100644
--- a/t/html/dual_iter.exp
+++ b/t/html/dual_iter.exp
@@ -1,15 +1,10 @@
-<html>
-  <head></head>
-  <body>
-    <dl class="dual_iter" id="service_plan">
-      <dt class="adstyle">the pros</dt>
-      <dd class="adstyle2">never have to worry about service again</dd>
-      <dt class="adstyle">the cons</dt>
-      <dd class="adstyle2">upfront extra charge on purchase</dd>
-      <dt class="adstyle">our choice</dt>
-      <dd class="adstyle2">go with the extended service plan</dd>
-      <dt class="adstyle">sample header</dt>
-      <dd class="adstyle2">sample data</dd>
-    </dl>
-  </body>
-</html>
+<dl class="dual_iter" id="service_plan">
+  <dt class="adstyle">the pros</dt>
+  <dd class="adstyle2">never have to worry about service again</dd>
+  <dt class="adstyle">the cons</dt>
+  <dd class="adstyle2">upfront extra charge on purchase</dd>
+  <dt class="adstyle">our choice</dt>
+  <dd class="adstyle2">go with the extended service plan</dd>
+  <dt class="adstyle">sample header</dt>
+  <dd class="adstyle2">sample data</dd>
+</dl>
diff --git a/t/html/fillinform/fillinform.exp b/t/html/fillinform.exp
similarity index 88%
rename from t/html/fillinform/fillinform.exp
rename to t/html/fillinform.exp
index bbe603e..75b3b6e 100644
--- a/t/html/fillinform/fillinform.exp
+++ b/t/html/fillinform.exp
@@ -1,7 +1,4 @@
-<html>
-  <head></head>
-  <body>
-    <div>
+<div>
       <h1>Dialer</h1>
       <form name="appform" id="appform" method="post">
         <div id="city_div"> City:
@@ -18,6 +15,4 @@
         </div>
         <input value="locate records" type="submit"/>
       </form>
-    </div>
-  </body>
-</html>
+</div>
diff --git a/t/html/fillinform/fillinform.initial b/t/html/fillinform.html
similarity index 100%
rename from t/html/fillinform/fillinform.initial
rename to t/html/fillinform.html
diff --git a/t/html/same_as/same_as.exp b/t/html/hashmap.exp
similarity index 100%
rename from t/html/same_as/same_as.exp
rename to t/html/hashmap.exp
diff --git a/t/html/same_as/same_as.initial b/t/html/hashmap.html
similarity index 100%
rename from t/html/same_as/same_as.initial
rename to t/html/hashmap.html
diff --git a/t/html/highlander-15.exp b/t/html/highlander-15.exp
index 48fe062..dbd4acf 100644
--- a/t/html/highlander-15.exp
+++ b/t/html/highlander-15.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="under18"> Sorry,
+<span id="age_dialog" klass="highlander"><span id="under18"> Sorry,
         you're not old enough to enter (and too dumb to lie about your age)
-      </span></span></body>
-</html>
+      </span></span>
diff --git a/t/html/highlander-5.exp b/t/html/highlander-5.exp
index 96df6fc..5baaa1d 100644
--- a/t/html/highlander-5.exp
+++ b/t/html/highlander-5.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="under10"> Hello,
+<span id="age_dialog" klass="highlander"><span id="under10"> Hello,
         does your mother know you're using her AOL account?
-      </span></span></body>
-</html>
+      </span></span>
diff --git a/t/html/highlander-50.exp b/t/html/highlander-50.exp
index 1f03edd..8511ff2 100644
--- a/t/html/highlander-50.exp
+++ b/t/html/highlander-50.exp
@@ -1,5 +1,2 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="welcome"> Welcome
-      </span></span></body>
-</html>
+<span id="age_dialog" klass="highlander"><span id="welcome"> Welcome
+      </span></span>
diff --git a/t/html/highlander2-15.exp b/t/html/highlander2-15.exp
index 20be935..56bd431 100644
--- a/t/html/highlander2-15.exp
+++ b/t/html/highlander2-15.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="under18"> Sorry,
+<span id="age_dialog" klass="highlander"><span id="under18"> Sorry,
         you're only <span id="age">15</span> (and too dumb to lie about your
-        age) </span></span></body>
-</html>
+        age) </span></span>
diff --git a/t/html/highlander2-27.exp b/t/html/highlander2-27.exp
index dd7b2fa..3671bbe 100644
--- a/t/html/highlander2-27.exp
+++ b/t/html/highlander2-27.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="welcome"> Welcome,
+<span id="age_dialog" klass="highlander"><span id="welcome"> Welcome,
         isn't it good to be <span id="age">27</span> years old?
-      </span></span></body>
-</html>
+</span></span>
diff --git a/t/html/highlander2-5.exp b/t/html/highlander2-5.exp
index b62e6e0..ecc6e88 100644
--- a/t/html/highlander2-5.exp
+++ b/t/html/highlander2-5.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"><span id="under10"> Hello,
+<span id="age_dialog" klass="highlander"><span id="under10"> Hello,
         little <span id="age">5</span>-year old, does your mother know you're
-        using her AOL account? </span></span></body>
-</html>
+        using her AOL account? </span></span>
diff --git a/t/html/highlander2-passover.exp b/t/html/highlander2-passover.exp
index 8de5305..8bfaa65 100644
--- a/t/html/highlander2-passover.exp
+++ b/t/html/highlander2-passover.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body><span id="age_dialog" klass="highlander"> <span id="under18"> Sorry,
+<span id="age_dialog" klass="highlander"> <span id="under18"> Sorry,
         you're only <span id="age">AGE</span> (and too dumb to lie about your
-        age) </span> </span></body>
-</html>
+        age) </span> </span>
diff --git a/t/html/iter.exp b/t/html/iter.exp
index 746633e..013b019 100644
--- a/t/html/iter.exp
+++ b/t/html/iter.exp
@@ -1,10 +1,8 @@
-<html>
-  <head></head>
-  <body>Here are the things I need from the store:
+<body>
+Here are the things I need from the store:
     <ul>
       <li class="store_items">bread</li>
       <li class="store_items">butter</li>
       <li class="store_items">vodka</li>
     </ul>
-  </body>
-</html>
+</body>
diff --git a/t/html/iter.html b/t/html/iter.html
index 289809f..3f609f1 100644
--- a/t/html/iter.html
+++ b/t/html/iter.html
@@ -1,4 +1,6 @@
+<body>
 Here are the things I need from the store:
 <ul>
 <li class="store_items">Sample item</li>
-</ul>
\ No newline at end of file
+</ul>
+</body>
diff --git a/t/html/iter2.exp b/t/html/iter2.exp
index 17148cf..992ffa3 100644
--- a/t/html/iter2.exp
+++ b/t/html/iter2.exp
@@ -1,6 +1,5 @@
-<html>
-  <head></head>
-  <body>Here are the type of people you meet at XYZ, inc:
+<div>
+Here are the type of people you meet at XYZ, inc:
     <dl>
       <dt>Programmer</dt>
       <dd>one who likes Perl and Seamstress</dd>
@@ -11,5 +10,4 @@
       <dt> Poet </dt>
       <dd> A relative of Edgar Allan Poe. </dd>
     </dl>
-  </body>
-</html>
+</div>
diff --git a/t/html/iter2.html b/t/html/iter2.html
index 1a93671..acb026e 100644
--- a/t/html/iter2.html
+++ b/t/html/iter2.html
@@ -1,3 +1,4 @@
+<div>
 Here are the type of people you meet at XYZ, inc:
 
     <dl>
@@ -25,3 +26,4 @@ Here are the type of people you meet at XYZ, inc:
 
 
     </dl>
+</div>
diff --git a/t/html/same_as.html b/t/html/same_as.html
deleted file mode 100644
index f70d378..0000000
--- a/t/html/same_as.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<html>
-<head>
-  <title>HO HO HA HA HA</title>
-</head>
-
-<body>
-  <table>
-    <tr sclass="tr" class="alt" align="left" valign="top">
-      <td sid="people_id">1</td>
-      <td sid="phone">(877) 255-3239</td>
-      <td sid="email"><a sid="a_email" href="mailto:jim@gmail.com">jim@gmail.com</a></td>
-    </tr>
-  </table>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/t/html/table-alt.exp b/t/html/table-alt.exp
index 60c9f06..9cff2c0 100644
--- a/t/html/table-alt.exp
+++ b/t/html/table-alt.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body>
     <table class="supply" id="load_data">
       <tr>
         <th>name</th>
@@ -38,5 +35,3 @@
         <td id="weight">230</td>
       </tr>
     </table>
-  </body>
-</html>
diff --git a/t/html/table.exp b/t/html/table.exp
index c11b8f4..95b8566 100644
--- a/t/html/table.exp
+++ b/t/html/table.exp
@@ -1,6 +1,3 @@
-<html>
-  <head></head>
-  <body>
     <table class="supply" id="load_data">
       <tr>
         <th>name</th>
@@ -38,5 +35,3 @@
         <td id="weight">230</td>
       </tr>
     </table>
-  </body>
-</html>
diff --git a/t/html/table2-tr_ld-coderef.html b/t/html/table2-tr_ld-coderef.html
deleted file mode 100644
index cffaba2..0000000
--- a/t/html/table2-tr_ld-coderef.html
+++ /dev/null
@@ -1,78 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <title>Complex HTML Table</title>
-  </head>
-
-  <body style="font-family: Arial, Helvetica, sans-serif" >
-    <h1>Complex HTML Table</h1>
-
-    <P>
-      This table comes from 
-      <a
-	href="http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.5">
-	the w3 spec on tables
-      </a>. I am using it to try out the <code>table2()</code> API call
-      that is part of the new release of 
-      <a
-	href=http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all>
-	<code>HTML::Element::Library</code>
-      </a>.
-    </p>
-
-    
-    <P>
-
-    <TABLE border="2" frame="hsides" rules="groups">
-      <CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
-      <COLGROUP align="center">
-      <COLGROUP align="left">
-      <COLGROUP align="center" span="2">
-      <COLGROUP align="center" span="3">
-      <THEAD valign="top">
-	<TR>
-	  <TH>Code-Page<BR>ID
-	  <TH>Name
-	  <TH>ACP
-	  <TH>OEMCP
-	  <TH>Windows<BR>NT 3.1
-	  <TH>Windows<BR>NT 3.51
-	  <TH>Windows<BR>95
-	  </th>
-	</tr>
-      <TBODY>
-	<TR><TD>1200<TD>Unicode (BMP of ISO/IEC-10646)<TD><TD><TD>X<TD>X<TD>*
-	<TR><TD>1250<TD>Windows 3.1 Eastern European<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1251<TD>Windows 3.1 Cyrillic<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1252<TD>Windows 3.1 US (ANSI)<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1253<TD>Windows 3.1 Greek<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1254<TD>Windows 3.1 Turkish<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1255<TD>Hebrew<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1256<TD>Arabic<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1257<TD>Baltic<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1361<TD>Korean (Johab)<TD>X<TD><TD><TD>**<TD>X
-	  </td>
-	</tr>
-      </tbody>
-      <TBODY>
-	<TR><TD>437<TD>MS-DOS United States<TD><TD>X<TD>X<TD>X<TD>X
-	<TR><TD>708<TD>Arabic (ASMO 708)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>709<TD>Arabic (ASMO 449+, BCON V4)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>710<TD>Arabic (Transparent Arabic)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>720<TD>Arabic (Transparent ASMO)<TD><TD>X<TD><TD><TD>X</td>
-	</tr>
-      </tbody>
-
-    </TABLE>
-
-
-
-
-    <hr>
-    <address><a href="mailto:metaperl@gmail.com">metaperl</a></address>
-<!-- Created: Fri Nov 25 08:48:48 PST 2005 -->
-<!-- hhmts start -->
-Last modified: Fri Nov 25 08:57:41 PST 2005
-<!-- hhmts end -->
-  </body>
-</html>
diff --git a/t/html/table2-tr_ld-default.html b/t/html/table2-tr_ld-default.html
deleted file mode 100644
index 544553b..0000000
--- a/t/html/table2-tr_ld-default.html
+++ /dev/null
@@ -1,80 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <title>Complex HTML Table</title>
-  </head>
-
-  <body style="font-family: Arial, Helvetica, sans-serif" >
-    <h1>Complex HTML Table</h1>
-
-    <P>
-      This table comes from 
-      <a
-	href="http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.5">
-	the w3 spec on tables
-      </a>. I am using it to try out the <code>table2()</code> API call
-      that is part of the new release of 
-      <a
-	href=http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all>
-	<code>HTML::Element::Library</code>
-      </a>.
-    </p>
-
-    
-    <P>
-
-    <TABLE border="2" frame="hsides" rules="groups"
-      summary="Code page support in different versions
-      of MS Windows.">
-      <CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
-      <COLGROUP align="center">
-      <COLGROUP align="left">
-      <COLGROUP align="center" span="2">
-      <COLGROUP align="center" span="3">
-      <THEAD valign="top">
-	<TR>
-	  <TH>Code-Page<BR>ID
-	  <TH>Name
-	  <TH>ACP
-	  <TH>OEMCP
-	  <TH>Windows<BR>NT 3.1
-	  <TH>Windows<BR>NT 3.51
-	  <TH>Windows<BR>95
-	  </th>
-	</tr>
-      <TBODY>
-	<TR><TD>1200<TD>Unicode (BMP of ISO/IEC-10646)<TD><TD><TD>X<TD>X<TD>*
-	<TR><TD>1250<TD>Windows 3.1 Eastern European<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1251<TD>Windows 3.1 Cyrillic<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1252<TD>Windows 3.1 US (ANSI)<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1253<TD>Windows 3.1 Greek<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1254<TD>Windows 3.1 Turkish<TD>X<TD><TD>X<TD>X<TD>X
-	<TR><TD>1255<TD>Hebrew<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1256<TD>Arabic<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1257<TD>Baltic<TD>X<TD><TD><TD><TD>X
-	<TR><TD>1361<TD>Korean (Johab)<TD>X<TD><TD><TD>**<TD>X
-	  </td>
-	</tr>
-      </tbody>
-      <TBODY>
-	<TR><TD>437<TD>MS-DOS United States<TD><TD>X<TD>X<TD>X<TD>X
-	<TR><TD>708<TD>Arabic (ASMO 708)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>709<TD>Arabic (ASMO 449+, BCON V4)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>710<TD>Arabic (Transparent Arabic)<TD><TD>X<TD><TD><TD>X
-	<TR><TD>720<TD>Arabic (Transparent ASMO)<TD><TD>X<TD><TD><TD>X</td>
-	</tr>
-      </tbody>
-
-    </TABLE>
-
-
-
-
-    <hr>
-    <address><a href="mailto:metaperl@gmail.com">metaperl</a></address>
-<!-- Created: Fri Nov 25 08:48:48 PST 2005 -->
-<!-- hhmts start -->
-Last modified: Fri Nov 25 08:57:41 PST 2005
-<!-- hhmts end -->
-  </body>
-</html>
diff --git a/t/html/table2-tr_ld_coderef.exp b/t/html/table2-tr_ld_coderef.exp
deleted file mode 100644
index 6df0c73..0000000
--- a/t/html/table2-tr_ld_coderef.exp
+++ /dev/null
@@ -1,134 +0,0 @@
-<html>
-  <head>
-    <title>Complex HTML Table</title>
-  </head>
-  <body style="font-family: Arial, Helvetica, sans-serif">
-    <h1>Complex HTML Table</h1>
-    <p> This table comes from <a
-        href="http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.5"> the
-        w3 spec on tables </a>. I am using it to try out the
-      <code>table2()</code> API call that is part of the new release of <a
-        href="http://search.cpan.org/search?query=Element%3A%3ALibrary&amp;mode=all">
-        <code>HTML::Element::Library</code> </a>. </p>
-    <p>
-      <table
-        summary="Code page support in different versions
-      of MS Windows."
-        frame="hsides" rules="groups" border="2">
-        <caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
-        <colgroup align="center"></colgroup>
-        <colgroup align="left"></colgroup>
-        <colgroup align="center" span="2"></colgroup>
-        <colgroup align="center" span="3">
-          <thead valign="top">
-            <tr>
-              <th>Code-Page<br>ID </th>
-              <th>Name </th>
-              <th>ACP </th>
-              <th>OEMCP </th>
-              <th>Windows<br>NT 3.1 </th>
-              <th>Windows<br>NT 3.51 </th>
-              <th>Windows<br>95 </th>
-            </tr>
-            <tbody>
-              <tr>
-                <td>1200</td>
-                <td>Unicode (BMP of ISO/IEC-10646)</td>
-                <td></td>
-                <td></td>
-                <td>X</td>
-                <td>X</td>
-                <td>* </td>
-              </tr>
-              <tr>
-                <td>1255</td>
-                <td>Hebrew</td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>1256</td>
-                <td>Arabic</td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>1257</td>
-                <td>Baltic</td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>1361</td>
-                <td>Korean (Johab)</td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td>**</td>
-                <td>X </td>
-              </tr>
-            </tbody>
-            <tbody>
-              <tr>
-                <td>437</td>
-                <td>MS-DOS United States</td>
-                <td></td>
-                <td>X</td>
-                <td>X</td>
-                <td>X</td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>708</td>
-                <td>Arabic (ASMO 708)</td>
-                <td></td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>709</td>
-                <td>Arabic (ASMO 449+, BCON V4)</td>
-                <td></td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>710</td>
-                <td>Arabic (Transparent Arabic)</td>
-                <td></td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td>X </td>
-              </tr>
-              <tr>
-                <td>720</td>
-                <td>Arabic (Transparent ASMO)</td>
-                <td></td>
-                <td>X</td>
-                <td></td>
-                <td></td>
-                <td>X</td>
-              </tr>
-            </tbody>
-          </thead>
-        </colgroup>
-      </table>
-      <hr>
-      <address><a href="mailto:metaperl@gmail.com">metaperl</a></address>
-      Last modified: Fri Nov 25 08:57:41 PST 2005 </p>
-  </body>
-</html>
diff --git a/t/iter.t b/t/iter.t
index 182abd1..6e86b44 100644
--- a/t/iter.t
+++ b/t/iter.t
@@ -1,23 +1,7 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-my $root = 't/html/iter';
-
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $tree = mktree 't/html/iter.html';
 my $li = $tree->look_down(class => 'store_items');
-
-my @items = qw(bread butter vodka);
-
-$tree->iter($li, @items);
-
-
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 
-      "HTML for generated li");
+$tree->iter($li, qw/bread butter vodka/);
+isxml $tree, 't/html/iter.exp', 'iter';
diff --git a/t/iter2.t b/t/iter2.t
index 8f3f312..5d48877 100644
--- a/t/iter2.t
+++ b/t/iter2.t
@@ -1,43 +1,31 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
+#!/usr/bin/perl
+use t::lib tests => 1;
 
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-my $root = 't/html/iter2';
-
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-my @items = (
-  [    Programmer => 'one who likes Perl and Seamstress', ],
-  [ DBA        => 'one who does business as', ],
-  [ Admin      => 'one who plays Tetris all day' ]
- );
+my $tree = mktree 't/html/iter2.html';
 
 $tree->iter2(
-  # default wrapper_ld ok
-  wrapper_data => \@items,
-  wrapper_proc => sub {
-    my ($container) = @_;
-
-    # only keep the last 2 dts and dds
-    my @content_list = $container->content_list;
-    $container->splice_content(0, @content_list - 2); 
-  },
-  # default item_ld is k00l
-  # default item_data is phrEsh
-  # default item_proc will do w0rk
-  splice       => sub {
-    my ($container, @item_elems) = @_;
-    $container->unshift_content(@item_elems);
-  },
-
-  debug => 1,
- );
-  
-
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "XML for generated li");
+	# default wrapper_ld ok
+	wrapper_data => [
+		[ Programmer => 'one who likes Perl and Seamstress' ],
+		[ DBA        => 'one who does business as' ],
+		[ Admin      => 'one who plays Tetris all day' ]
+	],
+	wrapper_proc => sub {
+		my ($container) = @_;
+
+		# only keep the last 2 dts and dds
+		my @content_list = $container->content_list;
+		$container->splice_content(0, @content_list - 2);
+	},
+	# default item_ld is k00l
+	# default item_data is phrEsh
+	# default item_proc will do w0rk
+	splice       => sub {
+		my ($container, @item_elems) = @_;
+		$container->unshift_content(@item_elems);
+	},
+
+	debug => $ENV{TEST_VERBOSE},
+);
+
+isxml $tree, 't/html/iter2.exp', 'iter2';
diff --git a/t/lib.pm b/t/lib.pm
new file mode 100644
index 0000000..87704c1
--- /dev/null
+++ b/t/lib.pm
@@ -0,0 +1,36 @@
+package t::lib;
+use strict;
+use warnings;
+
+use File::Slurp qw/read_file/;
+use HTML::TreeBuilder;
+use HTML::Element::Library;
+use Test::More ();
+use Test::XML;
+
+use parent qw/Exporter/;
+our @EXPORT = qw/is is_deeply is_xml slurp mktree isxml/;
+our $VERSION = '0.001'; # Exporter needs a $VERSION
+
+sub import {
+	my ($self, @args) = @_;
+	strict->import;
+	warnings->import;
+	Test::More->import(@args);
+
+	$self->export_to_level(1, $self);
+}
+
+sub slurp { scalar read_file @_ }
+
+sub mktree {
+	my ($file) = @_;
+	HTML::TreeBuilder->new_from_file($file)->disembowel;
+}
+
+sub isxml {
+	my ($tree, $file, $name) = @_;
+	my $res = ref $tree eq 'SCALAR' ? $$tree : $tree->as_XML;
+	my $exp = ref $file eq 'SCALAR' ? $$file : slurp $file;
+	is_xml $res, $exp, $name
+}
diff --git a/t/newchild.t b/t/newchild.t
index 43b641d..edeff5e 100644
--- a/t/newchild.t
+++ b/t/newchild.t
@@ -1,51 +1,10 @@
 #!/usr/bin/perl -T
+use lib '.';
+use t::lib tests => 1;
 
+my @list = map { [item => $_] } qw/bread butter beans/;
+my $initial_lol = [ note => [ list => [ item => 'sample' ] ] ];
+my ($new_lol) = HTML::Element::newchild($initial_lol, list => @list);
 
-use warnings;
-use strict;
-
-use Test::More;
-use Test::XML;
-
-BEGIN {
-    use_ok('HTML::TreeBuilder');
-    use_ok('HTML::Element::Library');
-}
-
-
-my $initial_lol = [ note => [ shopping => [ item => 'sample' ] ] ];
-my $new_lol = HTML::Element::newchild($initial_lol, shopping => shopping_items());
-
-
-sub shopping_items {
-  my @shopping_items = map { [ item => $_ ] } qw(bread butter beans);
-  @shopping_items;
-}
-
-my $expected =  [
-          'note',
-          [
-            'shopping',
-              [
-                'item',
-                'bread'
-              ],
-              [
-                'item',
-                'butter'
-              ],
-              [
-                'item',
-                'beans'
-              ]
-          ]
-        ];
-
-use Data::Dumper;
-warn Dumper($new_lol);
-
-is_deeply($new_lol, $expected, 'test unrolling');
-
-
-
-done_testing;
+my $expected = [note => [list => [item => 'bread'], [item => 'butter'], [item => 'beans']]];
+Test::More::is_deeply($new_lol, $expected, 'test unrolling');
diff --git a/t/passover.t b/t/passover.t
index 09951ab..2a0a901 100644
--- a/t/passover.t
+++ b/t/passover.t
@@ -1,32 +1,6 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub replace_age { 
-  my $branch = shift;
-  my $age = shift;
-  $branch->look_down(id => 'age')->replace_content($age);
-}
-
-
-sub tage {
-  my $age = shift;
-
-  my $tree = HTML::TreeBuilder->new_from_file('t/html/highlander2.html');
-
-  my $saved_child = $tree->passover('under18');
-
-  my $root = "t/html/highlander2-passover";
-
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "XML for $age");
-}
-
-
-tage('666');
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $tree = mktree 't/html/highlander2.html';
+$tree->passover('under18');
+isxml $tree, 't/html/highlander2-passover.exp', 'passover';
diff --git a/t/position.t b/t/position.t
index b48463d..93dbfb5 100644
--- a/t/position.t
+++ b/t/position.t
@@ -1,8 +1,5 @@
-use strict;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
+#!/usr/bin/perl
+use t::lib tests => 1;
 
 my $html =<<'EOHTML';
 <html>
@@ -21,17 +18,8 @@ my $html =<<'EOHTML';
 </html>
 EOHTML
 
-my $t1;
-my $lol;
-
-$t1 = HTML::TreeBuilder->new_from_content ( $html ) ;
-
-my $found= $t1->look_down(id => 'findme');
-
-
-my @found = $found->position;
-#warn "@found";
-
-is("@found", '-1 1 0 1 2');
-
+my $t1 = HTML::TreeBuilder->new_from_content ($html) ;
+my $found = $t1->look_down(id => 'findme');
 
+my $pos = join ' ', $found->position;
+is $pos, '-1 1 0 1 2';
diff --git a/t/prune.t b/t/prune.t
index af343db..654e656 100644
--- a/t/prune.t
+++ b/t/prune.t
@@ -1,22 +1,9 @@
 #!/usr/bin/perl -T
+use lib '.';
+use t::lib tests => 1;
 
-
-use warnings;
-use strict;
-
-use Test::More;
-use Test::XML;
-
-BEGIN {
-    use_ok('HTML::TreeBuilder');
-    use_ok('HTML::Element::Library');
-}
-
-
-
-my $root = HTML::TreeBuilder->new();
-my $html =<<'EOHTML';
-<html>    
+my $root = HTML::TreeBuilder->new_from_content(<<'EOHTML');
+<html>
 <head>
   <title></title>
 </head>
@@ -31,8 +18,6 @@ my $html =<<'EOHTML';
 </html>
 EOHTML
 
-$root->parse($html);
-$root->delete_ignorable_whitespace;
 $root->prune;
 
 my $expected = '
@@ -42,10 +27,4 @@ my $expected = '
 </html>
 ';
 
-#warn sprintf 'HTML:%s:HTML', $root->as_HTML;
-
-is_xml($root->as_HTML, $expected, 'test pruning');
-
-
-
-done_testing;
+isxml($root, \$expected, 'prune');
diff --git a/t/replace_content.t b/t/replace_content.t
index 40b0b7e..4723593 100644
--- a/t/replace_content.t
+++ b/t/replace_content.t
@@ -1,32 +1,16 @@
-use strict;
-use Test::More qw(no_plan);
-
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body',
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 'um, p < 4!', {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
+#!/usr/bin/perl
+use t::lib tests => 1;
 
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', 'um, p < 4!', {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
 $t1->look_down('_tag' => 'body')->replace_content('all gone!');
-is( $t1->as_HTML, '<html><head><title>I like stuff!</title></head><body lang="en-JP">all gone!</body></html>', "replaced all of body");
-
 
+isxml $t1, \'<html><head><title>I like stuff!</title></head><body id="corpus" lang="en-JP">all gone!</body></html>', 'replace_content';
diff --git a/t/set_child_content.t b/t/set_child_content.t
index 231ce7a..ce8a18c 100644
--- a/t/set_child_content.t
+++ b/t/set_child_content.t
@@ -1,33 +1,15 @@
-use strict;
-use Test::More qw(no_plan);
+#!/usr/bin/perl
+use t::lib tests => 1;
+
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', 'um, p < 4!', {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body', {id => 'corpus'},
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 'um, p < 4!', {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
-
-
-#$t1->look_down('_tag' => 'body')->replace_content('all gone!');
 $t1->set_child_content(id => 'corpus', 'all gone!');
-is( $t1->as_HTML, '<html><head><title>I like stuff!</title></head><body id="corpus" lang="en-JP">all gone!</body></html>', "replaced all of body");
-
-
+isxml $t1, \'<html><head><title>I like stuff!</title></head><body id="corpus" lang="en-JP">all gone!</body></html>', 'set_child_content';
diff --git a/t/sibdex.t b/t/sibdex.t
index 7c959f5..1181e06 100644
--- a/t/sibdex.t
+++ b/t/sibdex.t
@@ -1,32 +1,15 @@
-use strict;
-use Test::More qw(no_plan);
-
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body',
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 'um, p < 4!', {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
+#!/usr/bin/perl
+use t::lib tests => 1;
+
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', 'um, p < 4!', {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
 my $p = $t1->look_down('_tag' => 'body')->look_down(_tag => 'p');
-
-is($p->sibdex, 1, "does the p tag have 1 as its index");
-
-
+is $p->sibdex, 1, 'p tag has 1 as its index';
diff --git a/t/siblings.t b/t/siblings.t
index d1e753e..50b8c2f 100644
--- a/t/siblings.t
+++ b/t/siblings.t
@@ -1,40 +1,19 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl HTML-Element-Library.t'
-
-
-
-
-use strict;
-use Test::More qw(no_plan);
-
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body',
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 'um, p < 4!', {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
+#!/usr/bin/perl
+use t::lib tests => 3;
+
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', 'um, p < 4!', {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
 my $div = $t1->look_down('_tag' => 'body')->look_down(_tag => 'p');
 my @sibs = $div->siblings;
 
-is($sibs[0], 'stuff', "first sibling is simple text");
-is($sibs[2]->tag, 'div', "3rd tag a div tag");
-is(scalar @sibs, 4, "4 siblings total");
-
+is $sibs[0], 'stuff', "first sibling is simple text";
+is $sibs[2]->tag, 'div', "3rd tag is a div tag";
+is scalar @sibs, 4, "4 siblings total";
diff --git a/t/table-alt.t b/t/table-alt.t
index 9b84079..f759da4 100644
--- a/t/table-alt.t
+++ b/t/table-alt.t
@@ -1,54 +1,22 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
 use SimpleClass;
 
-my $root = 't/html/table-alt';
 my $o    = SimpleClass->new;
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
-$tree->table
- (
-    # tell seamstress where to find the table, via the method call
-    # ->look_down('id', $gi_table). Seamstress detaches the table from the
-    # HTML tree automatically if no table rows can be built
- 
-      gi_table    => 'load_data',
- 
-    # tell seamstress where to find the tr. This is a bit useless as
-    # the <tr> usually can be found as the first child of the parent
- 
-      gi_tr       => ['iterate1', 'iterate2'],
-      
-    # the model data to be pushed into the table
- 
-      table_data  => $o->load_data,
- 
-    # the way to take the model data and obtain one row
-    # if the table data were a hashref, we would do:
-    # my $key = (keys %$data)[0]; my $val = $data->{$key}; delete $data->{$key}
- 
-      tr_data     => sub { my ($self, $data) = @_;
-                          shift(@{$data}) ;
-                        },
- 
-    # the way to take a row of data and fill the <td> tags
- 
-      td_data     => sub { my ($tr_node, $tr_data) = @_;
-                          $tr_node->content_handler($_ => $tr_data->{$_})
-                            for qw(name age weight) }
- 
-   );
-
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 
-      "HTML for non-alternating table");
+my $tree = mktree 't/html/table-alt.html';
+
+$tree->table(
+	gi_table    => 'load_data',
+	gi_tr       => ['iterate1', 'iterate2'],
+	table_data  => $o->load_data,
+	tr_data     => sub {
+		my ($self, $data) = @_;
+		shift @{$data};
+	},
+	td_data     => sub {
+		my ($tr_node, $tr_data) = @_;
+		$tr_node->content_handler($_ => $tr_data->{$_}) for qw(name age weight)
+	});
+
+isxml $tree, 't/html/table-alt.exp', 'table (alternating)';
diff --git a/t/table.t b/t/table.t
index 2351038..fe9fbf4 100644
--- a/t/table.t
+++ b/t/table.t
@@ -1,54 +1,22 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
 use SimpleClass;
 
-my $root = 't/html/table';
 my $o    = SimpleClass->new;
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
-$tree->table
- (
-    # tell seamstress where to find the table, via the method call
-    # ->look_down('id', $gi_table). Seamstress detaches the table from the
-    # HTML tree automatically if no table rows can be built
- 
-      gi_table    => 'load_data',
- 
-    # tell seamstress where to find the tr. This is a bit useless as
-    # the <tr> usually can be found as the first child of the parent
- 
-      gi_tr       => 'data_row',
-      
-    # the model data to be pushed into the table
- 
-      table_data  => $o->load_data,
- 
-    # the way to take the model data and obtain one row
-    # if the table data were a hashref, we would do:
-    # my $key = (keys %$data)[0]; my $val = $data->{$key}; delete $data->{$key}
- 
-      tr_data     => sub { my ($self, $data) = @_;
-                          shift(@{$data}) ;
-                        },
- 
-    # the way to take a row of data and fill the <td> tags
- 
-      td_data     => sub { my ($tr_node, $tr_data) = @_;
-                          $tr_node->content_handler($_ => $tr_data->{$_})
-                            for qw(name age weight) }
- 
-   );
-
-  is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 
-      "HTML for non-alternating table");
+my $tree = mktree 't/html/table.html';
+
+$tree->table(
+	gi_table    => 'load_data',
+	gi_tr       => 'data_row',
+	table_data  => $o->load_data,
+	tr_data     => sub { 
+		my ($self, $data) = @_;
+		shift(@{$data}) ;
+	},
+	td_data     => sub {
+		my ($tr_node, $tr_data) = @_;
+		$tr_node->content_handler($_ => $tr_data->{$_}) for qw(name age weight)
+	});
+
+isxml $tree, 't/html/table.exp', 'table';
diff --git a/t/table2-table_ld.t b/t/table2-table_ld.t
index c53735a..1a359da 100644
--- a/t/table2-table_ld.t
+++ b/t/table2-table_ld.t
@@ -1,65 +1,43 @@
-# This might look like shell script, but it's actually -*- perl -*-
+#!/usr/bin/perl
 # Test the 3 possible look_down calls to table2()
 #   a = default
 #   b = supplied array ref
 #   c = supplied code ref
-
-use strict;
+use t::lib tests => 3;
 use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More;
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
 use data::table2;
 
-
 my $o    = data::table2->new;
 
 # a - default table_ld
 
-my $root = 't/html/table2';
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/table2.html';
 
 my $table = HTML::Element::Library::ref_or_ld(
-  $tree,
-  ['_tag' => 'table']
- );
+	$tree,
+	['_tag' => 'table']
+);
 
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down default';
 
 # b - arrayref table_ld
 
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
 $table = HTML::Element::Library::ref_or_ld(
-  $tree,
-  [frame => 'hsides', rules => 'groups']
+	$tree,
+	[frame => 'hsides', rules => 'groups']
  );
 
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down arrayref';
 
 # c - coderef table_ld
 
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
 $table = HTML::Element::Library::ref_or_ld(
-  $tree,
-  sub {
-    my ($t) = @_;
-    my $caption = $t->look_down('_tag' => 'caption');
-    $caption->parent;
-  }
- );
-
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
-
-
-done_testing;
+	$tree,
+	sub {
+		my ($t) = @_;
+		my $caption = $t->look_down('_tag' => 'caption');
+		$caption->parent;
+	}
+);
+
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down coderef';
diff --git a/t/table2-tr_ld.t b/t/table2-tr_ld.t
index 6e01c51..c685205 100644
--- a/t/table2-tr_ld.t
+++ b/t/table2-tr_ld.t
@@ -1,82 +1,54 @@
-# This might look like shell script, but it's actually -*- perl -*-
-# Test the 3 possible look_down calls to table2()
-#   a = default
-#   b = supplied array ref
-#   c = supplied code ref
-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Scalar::Listify;
-use Test::XML;
-
-use data::table2;
-
-
-my $o    = data::table2->new;
+#!/usr/bin/perl
+use t::lib tests => 3;
 
 # a - default table_ld
 
-my $root = 't/html/table2';
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/table2.html';
 
 my @tr = HTML::Element::Library::ref_or_ld(
-  $tree,
-  ['_tag' => 'tr']
- );
+	$tree,
+	['_tag' => 'tr']
+);
 
-is (scalar @tr, 16, 'default ld_tr');
+is (scalar @tr, 16, 'table2 tr look_down (default)');
 
 # b - arrayref tr_ld
 
-$root = 't/html/table2-tr_ld-arrayref';
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+$tree = mktree 't/html/table2-tr_ld-arrayref.html';
 
 my $tr = HTML::Element::Library::ref_or_ld(
-  $tree,
-  [class => 'findMe']
- );
+	$tree,
+	[class => 'findMe']
+);
 
-is_xml ($tr->as_XML, scalar File::Slurp::read_file("$root.exp"), $root);
+isxml $tr, 't/html/table2-tr_ld-arrayref.exp', 'table2 tr look_down (arrayref)';
 
 # c - coderef tr_ld
 # removes windows listings before returning @tr
 
-$root = 't/html/table2';
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+$tree = mktree 't/html/table2.html';
 
 @tr = HTML::Element::Library::ref_or_ld(
-  $tree,
-  sub {
-    my ($t) = @_;
-    my @tr = $t->look_down('_tag' => 'tr');
-    my @keep;
-    for my $tr (@tr) {
-
-      my @td = $tr->look_down ('_tag' => 'td') ;
-      my $detached;
-      for my $td (@td) {
-	if (grep { $_ =~ /Windows/ } $td->content_list) {
-	  $tr->detach();
-	  ++$detached;
-	  last;
+	$tree,
+	sub {
+		my ($t) = @_;
+		my @tr = $t->look_down('_tag' => 'tr');
+		my @keep;
+		for my $tr (@tr) {
+
+			my @td = $tr->look_down ('_tag' => 'td') ;
+			my $detached;
+			for my $td (@td) {
+				if (grep { $_ =~ /Windows/ } $td->content_list) {
+					$tr->detach;
+					++$detached;
+					last;
+				}
+			}
+			push @keep, $tr unless $detached;
+		}
+		@keep;
 	}
-      }
-      push @keep, $tr unless $detached;
-    }
-    @keep;
-  }
- );
-
-#warn $_->as_HTML, $/ for @tr;
+);
 
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root-tr_ld-coderef.exp"), $root);
+isxml $tree, 't/html/table2-tr_ld-coderef.exp', 'table2 tr look_down (coderef)';
diff --git a/t/table2.t b/t/table2.t
index f72096e..3566c63 100644
--- a/t/table2.t
+++ b/t/table2.t
@@ -1,52 +1,34 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More;
-use Test::XML;
-
-use Data::Dumper;
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
 use data::table2;
 
 my $root = 't/html/table2';
-my $o    = data::table2->new;
 my $d    = data::table2->load_data;
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-#warn 'D:', Dumper $d;
+my $tree = mktree 't/html/table2.html';
 
 for my $dataset (keys %$d) {
-  my %tbody = ('4dig' => 0, '3dig' => 1);
-  $tree->table2 (
-#    debug => 1,
-    table_data => $d->{$dataset},
-    tr_base_id => $dataset,
-    tr_ld => sub {
-      my $t = shift;
-      my $tbody = ($t->look_down('_tag' => 'tbody'))[$tbody{$dataset}];
-      my @tbody_child = $tbody->content_list;
-      $tbody_child[$_]->detach for (1 .. $#tbody_child) ;
-      $tbody->content_list;
-    },
-    td_proc => sub {
-      my ($tr, $data) = @_;
-      my @td = $tr->look_down('_tag' => 'td');
-      for my $i (0..$#td) {
-#	warn $i;
-	$td[$i]->splice_content(0, 1, $data->[$i]);
-      }
-    }
-   );
+	my %tbody = ('4dig' => 0, '3dig' => 1);
+	$tree->table2 (
+		debug => $ENV{TEST_VERBOSE},
+		table_data => $d->{$dataset},
+		tr_base_id => $dataset,
+		tr_ld => sub {
+			my $t = shift;
+			my $tbody = ($t->look_down('_tag' => 'tbody'))[$tbody{$dataset}];
+			my @tbody_child = $tbody->content_list;
+			$tbody_child[$_]->detach for (1 .. $#tbody_child) ;
+			$tbody->content_list;
+		},
+		td_proc => sub {
+			my ($tr, $data) = @_;
+			my @td = $tr->look_down('_tag' => 'td');
+			for my $i (0..$#td) {
+				#	warn $i;
+				$td[$i]->splice_content(0, 1, $data->[$i]);
+			}
+		}
+	);
 }
 
-
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 'genhtml');
-
-
-done_testing;
+isxml $tree, 't/html/table2.exp', 'table2';
diff --git a/t/unroll_select.t b/t/unroll_select.t
index a21c712..d29870a 100644
--- a/t/unroll_select.t
+++ b/t/unroll_select.t
@@ -1,31 +1,17 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
 
 use SelectData;
 
-my $root = 't/html/unroll_select';
-
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/unroll_select.html';
 
-$tree->unroll_select
- (
-   select_label     => 'clan_list', 
-   option_value     => sub { my $row = shift; $row->{clan_id} },
-   option_content   => sub { my $row = shift; $row->{clan_name} },
-   option_selected  => sub { my $row = shift; $row->{selected} },
-   data             => SelectData->load_data,
-   data_iter        => sub { my $data = shift; shift @$data }
-  );
+$tree->unroll_select(
+	select_label     => 'clan_list',
+	option_value     => sub { my $row = shift; $row->{clan_id} },
+	option_content   => sub { my $row = shift; $row->{clan_name} },
+	option_selected  => sub { my $row = shift; $row->{selected} },
+	data             => SelectData->load_data,
+	data_iter        => sub { my $data = shift; shift @$data });
 
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 
-      "HTML for non-alternating table");
+isxml ($tree, 't/html/unroll_select.exp', 'unroll_select');
diff --git a/t/wrap_content.t b/t/wrap_content.t
index 976420e..7c766bc 100644
--- a/t/wrap_content.t
+++ b/t/wrap_content.t
@@ -1,38 +1,18 @@
-use strict;
-use Test::More qw(no_plan);
+#!/usr/bin/perl
+use t::lib tests => 1;
 
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
-  (
-   $lol =
-   ['html',
-    ['head',
-     [ 'title', 'I like stuff!' ],
-    ],
-    ['body',
-     {
-      'lang', 'en-JP'},
-     'stuff',
-     ['p', 
-      ['span', {id => 'wrapme'},
-      'um, p < 4!', 
-       ],
-      {'class' => 'par123'}],
-     ['div', {foo => 'bar'}, '123'], # at 0.1.2
-     ['div', {jack => 'olantern'}, '456'], # at 0.1.2
-    ]
-   ]
-  )
-  ;
+my $t1 = HTML::Element->new_from_lol(
+	['html',
+	 ['head',
+	  [ 'title', 'I like stuff!' ]],
+	 ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+	  'stuff',
+	  ['p', ['span', {id => 'wrapme'}, 'um, p < 4!'], {'class' => 'par123'}],
+	  ['div', {foo => 'bar'}, '123'], # at 0.1.2
+	  ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
 
 my $bold = HTML::Element->new('b', id => 'wrapper');
 
-my $W = $t1->look_down('id' => 'wrapme');
-$W->wrap_content($bold);
-is( $W->as_HTML, '<span id="wrapme"><b id="wrapper">um, p &lt; 4!</b></span>', "wrapped text");
-
-
+my $w = $t1->look_down('id' => 'wrapme');
+$w->wrap_content($bold);
+isxml $w, \'<span id="wrapme"><b id="wrapper">um, p &lt; 4!</b></span>', 'wrap_content';
-- 
2.39.5