Simplified test suite

Change-Id: Ibd0d60eead2f3cedfd63e1347c96ca96fb697b40
diff --git a/t/index/base_paragraphs.t b/t/index/base_paragraphs.t
index 2ff64b4..7e606ba 100644
--- a/t/index/base_paragraphs.t
+++ b/t/index/base_paragraphs.t
@@ -3,37 +3,12 @@
 use warnings;
 use utf8;
 use Test::More;
+use lib 't/index';
+use TestInit;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Base', 'Paragraphs'), 'Add Structure');
 
diff --git a/t/index/base_sentences.t b/t/index/base_sentences.t
index 7de5cdf..06bdfda 100644
--- a/t/index/base_sentences.t
+++ b/t/index/base_sentences.t
@@ -3,37 +3,12 @@
 use warnings;
 use utf8;
 use Test::More;
+use lib 't/index';
+use TestInit;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Base', 'Sentences'), 'Add Structure');
 
diff --git a/t/index/connexor_morpho.t b/t/index/connexor_morpho.t
index 2790683..e977ebe 100644
--- a/t/index/connexor_morpho.t
+++ b/t/index/connexor_morpho.t
@@ -3,37 +3,12 @@
 use warnings;
 use utf8;
 use Test::More;
+use lib 't/index';
+use TestInit;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Connexor', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/connexor_phrase.t b/t/index/connexor_phrase.t
index 7cacd15..1c218c6 100644
--- a/t/index/connexor_phrase.t
+++ b/t/index/connexor_phrase.t
@@ -3,37 +3,12 @@
 use warnings;
 use utf8;
 use Test::More;
+use lib 't/index';
+use TestInit;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Connexor', 'Phrase'), 'Add Structure');
 
diff --git a/t/index/connexor_syntax.t b/t/index/connexor_syntax.t
index 33b7799..c32dc63 100644
--- a/t/index/connexor_syntax.t
+++ b/t/index/connexor_syntax.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Connexor', 'Syntax'), 'Add Structure');
 
diff --git a/t/index/corenlp_constituency.t b/t/index/corenlp_constituency.t
index c089e20..3e84c56 100644
--- a/t/index/corenlp_constituency.t
+++ b/t/index/corenlp_constituency.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('CoreNLP', 'Constituency'), 'Add Structure');
 
diff --git a/t/index/corenlp_ent.t b/t/index/corenlp_ent.t
index fbce1ee..edbc1a1 100644
--- a/t/index/corenlp_ent.t
+++ b/t/index/corenlp_ent.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('CoreNLP', 'NamedEntities', 'ne_dewac_175m_600'), 'Add Structure');
 
diff --git a/t/index/corenlp_morpho.t b/t/index/corenlp_morpho.t
index 7d933ed..916053e 100644
--- a/t/index/corenlp_morpho.t
+++ b/t/index/corenlp_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('CoreNLP', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/corenlp_sentences.t b/t/index/corenlp_sentences.t
index 6aeeace..4242010 100644
--- a/t/index/corenlp_sentences.t
+++ b/t/index/corenlp_sentences.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('CoreNLP', 'Sentences'), 'Add Structure');
 
diff --git a/t/index/glemm_morpho.t b/t/index/glemm_morpho.t
index 7773c9f..8959277 100644
--- a/t/index/glemm_morpho.t
+++ b/t/index/glemm_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Glemm', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/mate_dependency.t b/t/index/mate_dependency.t
index 821c4a6..807e11d 100644
--- a/t/index/mate_dependency.t
+++ b/t/index/mate_dependency.t
@@ -5,35 +5,10 @@
 use Test::More skip_all => 'Not yet implemented';
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Mate', 'Dependency'), 'Add Structure');
 
diff --git a/t/index/mate_morpho.t b/t/index/mate_morpho.t
index a7d977f..6400a42 100644
--- a/t/index/mate_morpho.t
+++ b/t/index/mate_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Mate', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/mate_morpho_attr.t b/t/index/mate_morpho_attr.t
index fc4dc45..792f139 100644
--- a/t/index/mate_morpho_attr.t
+++ b/t/index/mate_morpho_attr.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('Mate', 'MorphoAttr'), 'Add Structure');
 
diff --git a/t/index/opennlp_morpho.t b/t/index/opennlp_morpho.t
index 8aa24f1..82182a2 100644
--- a/t/index/opennlp_morpho.t
+++ b/t/index/opennlp_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('OpenNLP', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/opennlp_sentences.t b/t/index/opennlp_sentences.t
index beb62d7..73808d6 100644
--- a/t/index/opennlp_sentences.t
+++ b/t/index/opennlp_sentences.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('OpenNLP', 'Sentences'), 'Add Structure');
 
diff --git a/t/index/tt_morpho.t b/t/index/tt_morpho.t
index f1274ad..e529af8 100644
--- a/t/index/tt_morpho.t
+++ b/t/index/tt_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('TreeTagger', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/tt_sentences.t b/t/index/tt_sentences.t
index 5e4effc..04c5892 100644
--- a/t/index/tt_sentences.t
+++ b/t/index/tt_sentences.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('TreeTagger', 'Sentences'), 'Add Structure');
 
diff --git a/t/index/xip_constituency.t b/t/index/xip_constituency.t
index 3189e44..89972e4 100644
--- a/t/index/xip_constituency.t
+++ b/t/index/xip_constituency.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('XIP', 'Constituency'), 'Add Structure');
 
diff --git a/t/index/xip_dependency.t b/t/index/xip_dependency.t
index 8387ec7..446e5ad 100644
--- a/t/index/xip_dependency.t
+++ b/t/index/xip_dependency.t
@@ -5,37 +5,12 @@
 use Test::More skip_all => 'Not yet implemented';
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
-
-ok($tokens->add('CoreNLP', 'Dependency'), 'Add Structure');
+ok($tokens->add('XIP', 'Dependency'), 'Add Structure');
 
 my $data = $tokens->to_data->{data};
 
diff --git a/t/index/xip_morpho.t b/t/index/xip_morpho.t
index f4e0afd..01aed9e 100644
--- a/t/index/xip_morpho.t
+++ b/t/index/xip_morpho.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('XIP', 'Morpho'), 'Add Structure');
 
diff --git a/t/index/xip_sentences.t b/t/index/xip_sentences.t
index 2419a69..b9f5a66 100644
--- a/t/index/xip_sentences.t
+++ b/t/index/xip_sentences.t
@@ -5,35 +5,10 @@
 use Test::More;
 use Scalar::Util qw/weaken/;
 use Data::Dumper;
+use lib 't/index';
+use TestInit;
 
-use_ok('KorAP::Document');
-
-use File::Basename 'dirname';
-use File::Spec::Functions 'catdir';
-
-my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
-
-ok(my $doc = KorAP::Document->new(
-  path => $path . '/'
-), 'Load Korap::Document');
-
-like($doc->path, qr!$path/$!, 'Path');
-ok($doc->parse, 'Parse document');
-
-ok($doc->primary->data, 'Primary data in existence');
-is($doc->primary->data_length, 129, 'Data length');
-
-use_ok('KorAP::Tokenizer');
-
-ok(my $tokens = KorAP::Tokenizer->new(
-  path => $doc->path,
-  doc => $doc,
-  foundry => 'OpenNLP',
-  layer => 'Tokens',
-  name => 'tokens'
-), 'New Tokenizer');
-
-ok($tokens->parse, 'Parse');
+ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens');
 
 ok($tokens->add('XIP', 'Sentences'), 'Add Structure');