diff --git a/Makefile.am b/Makefile.am
index 828d228ae2c58792df9dc02a3d5b75473661bb5d..d2c9cab7f43ea10c61c3a9fc24304bfbe1c015b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS = src
 
 EXTRA_DIST = \
+	tests \
 	sieve/* \
 	doc/* \
     COPYING.LGPL \
@@ -12,5 +13,35 @@ ChangeLog: .hg/dirstate
 	hg log --style=changelog > ChangeLog
 endif
 
-test:
-	$(MAKE) -C src/testsuite test
+# Testsuite tests
+
+TESTSUITE_BIN = $(top_srcdir)/src/testsuite/testsuite
+
+test_cases = \
+	tests/testsuite.svtest\
+	tests/control-structures.svtest \
+	tests/exists.svtest \
+	tests/lexer.svtest \
+	tests/comparators/core.svtest \
+	tests/match-types/is.svtest \
+	tests/match-types/contains.svtest \
+	tests/match-types/matches.svtest \
+	tests/match-types/relational.svtest \
+	tests/address-parts/subaddress.svtest \
+	tests/extensions/encoded-character.svtest \
+	tests/extensions/envelope.svtest \
+	tests/extensions/variables/basic.svtest \
+	tests/extensions/variables/match.svtest \
+	tests/extensions/include/variables.svtest \
+	tests/extensions/imapflags/basic.svtest \
+	tests/extensions/imapflags/rfc.svtest \
+	tests/compile/compile.svtest \
+	tests/compile/compile-examples.svtest \
+	tests/compile/errors.svtest
+
+$(test_cases):
+	@$(TESTSUITE_BIN) $@
+
+.PHONY: $(test_cases)
+
+test: $(test_cases)
diff --git a/configure.in b/configure.in
index 92ff0e2020ecdcc3df2df7b766f29a20e2f7ae1d..e100a28564b3f92b0cfd8bf5ed48e4534b425f36 100644
--- a/configure.in
+++ b/configure.in
@@ -54,9 +54,6 @@ AC_SUBST(MODULE_LIBS)
 AC_SUBST(dovecot_incdir)
 AC_SUBST(moduledir)
 
-TESTSUITE_BIN="\$(top_srcdir)/src/testsuite/testsuite"
-AC_SUBST(TESTSUITE_BIN)
-
 AC_CONFIG_FILES([
 Makefile
 src/Makefile
diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am
index 3fdd8a331d03f7054682ebb720ac32439b65417a..bcb5c5b8daa6766d5abe5282eb86d52f95f81b0b 100644
--- a/src/testsuite/Makefile.am
+++ b/src/testsuite/Makefile.am
@@ -62,34 +62,3 @@ noinst_HEADERS = \
 	namespaces.h \
 	mail-raw.h
 
-# Testsuite tests
-
-EXTRA_DIST = tests
-
-test_cases = \
-    tests/testsuite.svtest\
-    tests/control-structures.svtest \
-	tests/exists.svtest \
-	tests/lexer.svtest \
-	tests/comparators/core.svtest \
-	tests/match-types/is.svtest \
-	tests/match-types/contains.svtest \
-	tests/match-types/matches.svtest \
-	tests/match-types/relational.svtest \
-	tests/address-parts/subaddress.svtest \
-	tests/extensions/encoded-character.svtest \
-	tests/extensions/envelope.svtest \
-	tests/extensions/variables/basic.svtest \
-	tests/extensions/variables/match.svtest \
-	tests/extensions/include/variables.svtest \
-	tests/extensions/imapflags/basic.svtest \
-	tests/extensions/imapflags/rfc.svtest \
-	tests/compile/compile.svtest \
-	tests/compile/compile-examples.svtest \
-	tests/compile/errors.svtest 
-
-$(test_cases): 
-	@$(TESTSUITE_BIN) $@
-.PHONY: $(test_cases)
-
-test: $(test_cases)
diff --git a/src/testsuite/tests/address-parts/subaddress.svtest b/tests/address-parts/subaddress.svtest
similarity index 100%
rename from src/testsuite/tests/address-parts/subaddress.svtest
rename to tests/address-parts/subaddress.svtest
diff --git a/src/testsuite/tests/comparators/core.svtest b/tests/comparators/core.svtest
similarity index 100%
rename from src/testsuite/tests/comparators/core.svtest
rename to tests/comparators/core.svtest
diff --git a/src/testsuite/tests/compile/compile-examples.svtest b/tests/compile/compile-examples.svtest
similarity index 52%
rename from src/testsuite/tests/compile/compile-examples.svtest
rename to tests/compile/compile-examples.svtest
index b1161e47498d91f4ad16dfbde5a4f58d45751a6e..b8ad1978035e7e4a1b849f7f24960cfdba8b956f 100644
--- a/src/testsuite/tests/compile/compile-examples.svtest
+++ b/tests/compile/compile-examples.svtest
@@ -3,49 +3,49 @@ require "vnd.dovecot.testsuite";
 # Compile all example scripts
 
 test "Elvey example" {
-	if not test_compile "../../../../sieve/examples/elvey.sieve" {
+	if not test_compile "../../sieve/examples/elvey.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "M. Johnson example" {
-	if not test_compile "../../../../sieve/examples/mjohnson.sieve" {
+	if not test_compile "../../sieve/examples/mjohnson.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "RFC 3028 example" {
-	if not test_compile "../../../../sieve/examples/rfc3028.sieve" {
+	if not test_compile "../../sieve/examples/rfc3028.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "Sieve examples" {
-	if not test_compile "../../../../sieve/examples/sieve_examples.sieve" {
+	if not test_compile "../../sieve/examples/sieve_examples.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "Vivil example" {
-	if not test_compile "../../../../sieve/examples/vivil.sieve" {
+	if not test_compile "../../sieve/examples/vivil.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "Jerry example" {
-	if not test_compile "../../../../sieve/examples/jerry.sieve" {
+	if not test_compile "../../sieve/examples/jerry.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "M. Klose example" {
-	if not test_compile "../../../../sieve/examples/mklose.sieve" {
+	if not test_compile "../../sieve/examples/mklose.sieve" {
 		test_fail "could not compile";
 	}
 }
 
 test "Sanjay example" {
-	if not test_compile "../../../../sieve/examples/sanjay.sieve" {
+	if not test_compile "../../sieve/examples/sanjay.sieve" {
 		test_fail "could not compile";
 	}
 }
diff --git a/src/testsuite/tests/compile/compile.svtest b/tests/compile/compile.svtest
similarity index 100%
rename from src/testsuite/tests/compile/compile.svtest
rename to tests/compile/compile.svtest
diff --git a/src/testsuite/tests/compile/errors.svtest b/tests/compile/errors.svtest
similarity index 100%
rename from src/testsuite/tests/compile/errors.svtest
rename to tests/compile/errors.svtest
diff --git a/src/testsuite/tests/compile/errors/address-part.sieve b/tests/compile/errors/address-part.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/address-part.sieve
rename to tests/compile/errors/address-part.sieve
diff --git a/src/testsuite/tests/compile/errors/address.sieve b/tests/compile/errors/address.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/address.sieve
rename to tests/compile/errors/address.sieve
diff --git a/src/testsuite/tests/compile/errors/encoded-character.sieve b/tests/compile/errors/encoded-character.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/encoded-character.sieve
rename to tests/compile/errors/encoded-character.sieve
diff --git a/src/testsuite/tests/compile/errors/envelope.sieve b/tests/compile/errors/envelope.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/envelope.sieve
rename to tests/compile/errors/envelope.sieve
diff --git a/src/testsuite/tests/compile/errors/header.sieve b/tests/compile/errors/header.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/header.sieve
rename to tests/compile/errors/header.sieve
diff --git a/src/testsuite/tests/compile/errors/if.sieve b/tests/compile/errors/if.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/if.sieve
rename to tests/compile/errors/if.sieve
diff --git a/src/testsuite/tests/compile/errors/keep.sieve b/tests/compile/errors/keep.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/keep.sieve
rename to tests/compile/errors/keep.sieve
diff --git a/src/testsuite/tests/compile/errors/require.sieve b/tests/compile/errors/require.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/require.sieve
rename to tests/compile/errors/require.sieve
diff --git a/src/testsuite/tests/compile/errors/size.sieve b/tests/compile/errors/size.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/size.sieve
rename to tests/compile/errors/size.sieve
diff --git a/src/testsuite/tests/compile/errors/stop.sieve b/tests/compile/errors/stop.sieve
similarity index 100%
rename from src/testsuite/tests/compile/errors/stop.sieve
rename to tests/compile/errors/stop.sieve
diff --git a/src/testsuite/tests/compile/redirect.sieve b/tests/compile/redirect.sieve
similarity index 100%
rename from src/testsuite/tests/compile/redirect.sieve
rename to tests/compile/redirect.sieve
diff --git a/src/testsuite/tests/compile/trivial.sieve b/tests/compile/trivial.sieve
similarity index 100%
rename from src/testsuite/tests/compile/trivial.sieve
rename to tests/compile/trivial.sieve
diff --git a/src/testsuite/tests/control-structures.svtest b/tests/control-structures.svtest
similarity index 100%
rename from src/testsuite/tests/control-structures.svtest
rename to tests/control-structures.svtest
diff --git a/src/testsuite/tests/exists.svtest b/tests/exists.svtest
similarity index 100%
rename from src/testsuite/tests/exists.svtest
rename to tests/exists.svtest
diff --git a/src/testsuite/tests/extensions/encoded-character.svtest b/tests/extensions/encoded-character.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/encoded-character.svtest
rename to tests/extensions/encoded-character.svtest
diff --git a/src/testsuite/tests/extensions/envelope.svtest b/tests/extensions/envelope.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/envelope.svtest
rename to tests/extensions/envelope.svtest
diff --git a/src/testsuite/tests/extensions/imapflags/basic.svtest b/tests/extensions/imapflags/basic.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/imapflags/basic.svtest
rename to tests/extensions/imapflags/basic.svtest
diff --git a/src/testsuite/tests/extensions/imapflags/rfc.svtest b/tests/extensions/imapflags/rfc.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/imapflags/rfc.svtest
rename to tests/extensions/imapflags/rfc.svtest
diff --git a/src/testsuite/tests/extensions/include/variables-included1.sieve b/tests/extensions/include/variables-included1.sieve
similarity index 100%
rename from src/testsuite/tests/extensions/include/variables-included1.sieve
rename to tests/extensions/include/variables-included1.sieve
diff --git a/src/testsuite/tests/extensions/include/variables-included2.sieve b/tests/extensions/include/variables-included2.sieve
similarity index 100%
rename from src/testsuite/tests/extensions/include/variables-included2.sieve
rename to tests/extensions/include/variables-included2.sieve
diff --git a/src/testsuite/tests/extensions/include/variables-included3.sieve b/tests/extensions/include/variables-included3.sieve
similarity index 100%
rename from src/testsuite/tests/extensions/include/variables-included3.sieve
rename to tests/extensions/include/variables-included3.sieve
diff --git a/src/testsuite/tests/extensions/include/variables.svtest b/tests/extensions/include/variables.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/include/variables.svtest
rename to tests/extensions/include/variables.svtest
diff --git a/src/testsuite/tests/extensions/variables/basic.svtest b/tests/extensions/variables/basic.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/variables/basic.svtest
rename to tests/extensions/variables/basic.svtest
diff --git a/src/testsuite/tests/extensions/variables/match.svtest b/tests/extensions/variables/match.svtest
similarity index 100%
rename from src/testsuite/tests/extensions/variables/match.svtest
rename to tests/extensions/variables/match.svtest
diff --git a/src/testsuite/tests/header.svtest b/tests/header.svtest
similarity index 100%
rename from src/testsuite/tests/header.svtest
rename to tests/header.svtest
diff --git a/src/testsuite/tests/lexer.svtest b/tests/lexer.svtest
similarity index 100%
rename from src/testsuite/tests/lexer.svtest
rename to tests/lexer.svtest
diff --git a/src/testsuite/tests/match-types/contains.svtest b/tests/match-types/contains.svtest
similarity index 100%
rename from src/testsuite/tests/match-types/contains.svtest
rename to tests/match-types/contains.svtest
diff --git a/src/testsuite/tests/match-types/is.svtest b/tests/match-types/is.svtest
similarity index 100%
rename from src/testsuite/tests/match-types/is.svtest
rename to tests/match-types/is.svtest
diff --git a/src/testsuite/tests/match-types/matches.svtest b/tests/match-types/matches.svtest
similarity index 100%
rename from src/testsuite/tests/match-types/matches.svtest
rename to tests/match-types/matches.svtest
diff --git a/src/testsuite/tests/match-types/relational.svtest b/tests/match-types/relational.svtest
similarity index 100%
rename from src/testsuite/tests/match-types/relational.svtest
rename to tests/match-types/relational.svtest
diff --git a/src/testsuite/tests/testsuite.svtest b/tests/testsuite.svtest
similarity index 100%
rename from src/testsuite/tests/testsuite.svtest
rename to tests/testsuite.svtest