--- a/Makefile.am
+++ b/Makefile.am
@@ -55,6 +55,8 @@ gexiv2_vapi.stamp: $(top_builddir)/GExiv
 			      $(top_builddir)/GExiv2-0.10.gir $(abs_top_srcdir)/vapi/gexiv2-custom.vala
 	echo timestmap > $(@F)
 
+CLEANFILES = gexiv2.vapi gexiv2_vapi.stamp
+
 dist_vapi_DATA = gexiv2.vapi
 EXTRA_DIST += $(top_srcdir)/vapi/GExiv2-0.10.metadata gexiv2.vapi gexiv2_vapi.stamp $(top_srcdir)/vapi/gexiv2-custom.vala
 DISTCLEANFILES = gexiv2.vapi gexiv2_vapi.stamp
@@ -97,18 +99,7 @@ if PLATFORM_WIN32
 no_undefined = -no-undefined
 endif
 
-# REQUIRED_CFLAGS absolutely get appended to CFLAGS, whatever the
-# the value of CFLAGS in the environment.
-REQUIRED_CXXFLAGS=
-
-# Because -fPIC can interfere with compilation on 32-bit platforms but
-# is absolutely necessary for AMD64, we check what the target machine's
-# word size is, and set our required flags based upon that.
-if WORD_64
-REQUIRED_CXXFLAGS += -fPIC -DPIC
-endif
-
-AM_CXXFLAGS = $(REQUIRED_CXXFLAGS) -I$(top_builddir)/gexiv2 $(WARN_CXXFLAGS)
+AM_CXXFLAGS = -I$(top_builddir)/gexiv2 $(WARN_CXXFLAGS)
 
 $(GEXIV2_sources): gexiv2/gexiv2-version.h
 
@@ -130,22 +121,9 @@ clean-local:
 	rm -rf test/python/gi test/python/__pycache__
 
 # Tests and utilities #
+#
 
-if ENABLE_TESTS
-
-tests: test/gexiv2-dump test/python2 test/python3
-
-test/gexiv2-dump: test/gexiv2-dump.vala
-	valac -g --enable-checking --vapidir=. --pkg gexiv2 $< -o $@
-
-test/python/gi/overrides/GExiv2.py:
-	[ -d $(dir $@) ] || mkdir -p $(dir $@)
-	ln -sf ../../../../GExiv2.py $@
-
-test/python%: $(TYPELIB_FILES) test/python/gi/overrides/GExiv2.py
-	LD_LIBRARY_PATH=.libs GI_TYPELIB_PATH=. PYTHONPATH=test/python python$* -m unittest gexiv2
-
-endif
+include check.am
 
 # Optional Introspection #
 
@@ -168,5 +146,5 @@ GExiv2_@GIR_VERSION_U@_gir_NAMESPACE = G
 GExiv2_@GIR_VERSION_U@_gir_VERSION = $(GIR_VERSION)
 INTROSPECTION_GIRS += GExiv2-$(GIR_VERSION).gir
 
-CLEANFILES = $(gir_DATA) $(typelib_DATA)
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
 endif
--- /dev/null
+++ b/check.am
@@ -0,0 +1,42 @@
+TESTS_ENVIRONMENT = \
+	G_SLICE=always-malloc \
+	LD_LIBRARY_PATH=$(top_builddir)/.libs:$(LD_LIBRARY_PATH) \
+	GI_TYPELIB_PATH=$(top_builddir) \
+	PYTHONPATH=$(top_srcdir)/test/python \
+	MALLOC_CHECK_=2 \
+	MALLOC_PERTURB_=$$((RANDOM % 255))
+
+tests: check
+
+TESTS = test/gexiv2-regression
+
+check_PROGRAMS = test/gexiv2-regression
+
+test_gexiv2_regression_SOURCES = test/gexiv2-regression.c
+
+if PYTHON2_PATH
+TESTS += test/python2-test
+endif
+
+if PYTHON3_PATH
+TESTS += test/python3-test
+endif
+
+if HAVE_VALAC
+check_PROGRAMS += test/gexiv2-dump
+test_gexiv2_dump_SOURCES = test/gexiv2-dump.vala
+endif
+
+AM_VALAFLAGS = --pkg gexiv2 --pkg glib-2.0 --vapidir=$(top_srcdir)
+
+LDADD = \
+	$(top_builddir)/libgexiv2.la \
+	$(GLIB_LIBS) $(EXIV2_LIBS)
+AM_CFLAGS = \
+	$(GLIB_CFLAGS) $(EXIV2_CFLAGS) \
+	-I $(top_srcdir) -DSAMPLE_PATH="\"$(abs_top_srcdir)/test\""
+
+EXTRA_DIST += \
+	test/sample-author-badencoding.jpg \
+	test/CaorVN.jpeg
+
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,8 @@
-AC_INIT([gexiv2], [0.10.4], [gexiv2-list@gnome.org], [gexiv2], [https://wiki.gnome.org/Projects/gexiv2])
++AC_INIT([gexiv2],
++        [0.10.4],
++        [https://bugzilla.gnome.org/enter_bug.cgi?product=gexiv2],
++        [gexiv2],
++        [https://wiki.gnome.org/Projects/gexiv2])
 AC_PREREQ(2.54)
 
 AC_CONFIG_MACRO_DIR([m4])
@@ -10,6 +14,12 @@ AM_INIT_AUTOMAKE([1.11 -Wall no-define f
 AM_MAINTAINER_MODE([enable])
 AM_SILENT_RULES([yes])
 
+##############
+# Debug Mode #
+##############
+
+AX_CHECK_ENABLE_DEBUG([no])
+
 AM_PROG_AR
 LT_PREREQ([2.2])
 LT_INIT([disable-static win32-dll])
@@ -89,37 +99,20 @@ PKG_CHECK_MODULES(EXIV2,
                   ,
                   AC_MSG_ERROR([exiv2 is required. Please install it.]))
 
-##############
-# Debug Mode #
-##############
-
-AC_MSG_CHECKING([debugging mode])
-AC_ARG_ENABLE(debug,
-              [  --enable-debug          enable debug mode [[default=no]]],
-              if eval "test x$enable_debug = xyes"; then
-              DEBUG_CFLAGS="-O0"
-              fi)
-
-if test -n "$DEBUG_CFLAGS"; then
-    AC_MSG_RESULT([yes])
-    if test -z "$CXXFLAGS"; then
-        CXXFLAGS="-O0 -g -pipe -nostdlib -shared"
-    else
-        CXXFLAGS="$DEBUG_CFLAGS $CXXFLAGS"
-    fi
-else
-    AC_MSG_RESULT([no])
-    if test -z "$CXXFLAGS"; then
-        CXXFLAGS="-O2 -g -pipe -nostdlib -shared"
-    fi
-fi
-
 #################
 # Introspection #
 #################
 
 GOBJECT_INTROSPECTION_CHECK([0.6.4])
 
+AC_PATH_PROGS([PYTHON2_PATH],[python2],[:])
+AC_SUBST(PYTHON2_PATH)
+AM_CONDITIONAL([PYTHON2_PATH], [test "x$PYTHON2_PATH" != "x:"])
+
+AC_PATH_PROGS([PYTHON3_PATH],[python3],[:])
+AC_SUBST(PYTHON3_PATH)
+AM_CONDITIONAL([PYTHON3_PATH], [test "x$PYTHON3_PATH" != "x:"])
+
 AC_ARG_WITH([python2-girdir],
             AS_HELP_STRING([--with-python2-girdir],
                              [Set the GI override file install dir]),
@@ -134,22 +127,28 @@ AC_ARG_WITH([python3-girdir],
 
 enable_python2="no (introspection disabled)"
 enable_python3="no (introspection disabled)"
-if test "x$found_introspection" = "xyes"; then
+PYTHON_CODE="import gi; print(gi._overridesdir)"
+AS_IF([test "x$found_introspection" = "xyes"],
+      [
     # Used to determine where Python wants the .gi file to be installed ...
     # if Python is not installed, PYTHON2 and PYTHON3 will be empty
-    PYTHON="import gi; print(gi._overridesdir)"
     AS_IF([test "x$ac_py2girdir" = "x"],
     [
-        PYTHON2_GIDIR=$(python2 -c "$PYTHON")
+        AS_IF([test "x$PYTHON2_PATH" != "x:"],
+              [PYTHON2_GIDIR=$($PYTHON2_PATH -c "$PYTHON_CODE")],
+              [PYTHON2_GIDIR=""])
     ],
     [
         PYTHON2_GIDIR=$ac_py2girdir
     ])
     AC_MSG_RESULT([Python2 GObject Introspection directory: $PYTHON2_GIDIR])
 
+
     AS_IF([test "x$ac_py3girdir" = "x"],
     [
-        PYTHON3_GIDIR=$(python3 -c "$PYTHON")
+        AS_IF([test "x$PYTHON3_PATH" != "x:"],
+              [PYTHON3_GIDIR=$($PYTHON3_PATH -c "$PYTHON_CODE")],
+              [PYTHON3_GIDIR=""])
     ],
     [
         PYTHON3_GIDIR=$ac_py3girdir
@@ -163,7 +162,7 @@ if test "x$found_introspection" = "xyes"
 
     AC_SUBST(PYTHON2_GIDIR)
     AC_SUBST(PYTHON3_GIDIR)
-fi
+    ])
 AM_CONDITIONAL(HAS_PYTHON2, test "x$PYTHON2_GIDIR" != "x")
 AM_CONDITIONAL(HAS_PYTHON3, test "x$PYTHON3_GIDIR" != "x")
 
@@ -171,32 +170,8 @@ AM_CONDITIONAL(HAS_PYTHON3, test "x$PYTH
 # Tests and utilities #
 #######################
 
-AC_ARG_ENABLE(tests, [  --enable-tests          enable tests and utilities (requires Vala) [[default=no]]],
-              if eval "test x$enable_tests = xno"; then
-              enable_tests=no
-              else
-              enable_tests=yes
-              fi,
-              enable_tests=no)
-
-if test "x$enable_tests" != "xno"; then
-    AC_CHECK_TOOL([VALAC], [valac], [:])
-    if test "x$VALAC" = "x:"; then
-        enable_tests="no (missing valac)"
-    fi
-fi
-AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = "xyes")
-
-AC_MSG_CHECKING([enable tests])
-AC_MSG_RESULT([$enable_tests])
-
-###################
-# Check Word Size #
-###################
-
-AC_CHECK_SIZEOF([int *])
-AC_SUBST(SIZEOF_INT_P)
-AM_CONDITIONAL(WORD_64, test "x$SIZEOF_INT_P" = "x8" )
+AC_CHECK_TOOL([VALAC], [valac], [:])
+AM_CONDITIONAL([HAVE_VALAC], [test "x$VALAC" != "x:"])
 
 ###########################
 # Check target architecture
@@ -211,29 +186,6 @@ case x"$target" in
 esac
 AC_MSG_RESULT([$target_or_host])
 
-case "$target_or_host" in
-    i*86-*-*)
-        have_x86=yes
-        AC_DEFINE(ARCH_X86, 1, [Define to 1 if you are compiling for ix86.])
-    ;;
-    x86_64-*-*)
-        have_x86=yes
-        AC_DEFINE(ARCH_X86, 1, [Define to 1 if you are compiling for ix86.])
-        AC_DEFINE(ARCH_X86_64, 1, [Define to 1 if you are compiling for amd64.])
-    ;;
-    ppc-*-* | powerpc-*)
-        have_ppc=yes
-        AC_DEFINE(ARCH_PPC, 1, [Define to 1 if you are compiling for PowerPC.])
-    ;;
-    ppc64-*-* | powerpc64-*)
-        have_ppc=yes
-        AC_DEFINE(ARCH_PPC, 1, [Define to 1 if you are compiling for PowerPC.])
-        AC_DEFINE(ARCH_PPC64, 1, [Define to 1 if you are compiling for PowerPC64.])
-    ;;
-    *)
-    ;;
-esac
-
 #################
 # Check for Win32
 #################
@@ -274,8 +226,9 @@ Options:
     Introspection:      $found_introspection
     Python2 binding:    $enable_python2
     Python3 binding:    $enable_python3
-    Tests and utils:    $enable_tests
 ])
+AC_CONFIG_FILES([test/python2-test], [chmod +x test/python2-test])
+AC_CONFIG_FILES([test/python3-test], [chmod +x test/python3-test])
 
 if test "x$enable_tests" = "xyes"; then
 AC_MSG_RESULT([To build tests and utiliies, run "make tests".])
--- a/gexiv2.vapi
+++ /dev/null
@@ -1,164 +0,0 @@
-/* gexiv2.vapi generated by vapigen-0.32, do not modify. */
-
-[CCode (cprefix = "GExiv2", gir_namespace = "GExiv2", gir_version = "0.10", lower_case_cprefix = "gexiv2_")]
-namespace GExiv2 {
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public class Metadata : GLib.Object {
-		[CCode (has_construct_function = false)]
-		public Metadata ();
-		public void clear ();
-		public void clear_comment ();
-		public void clear_exif ();
-		public void clear_iptc ();
-		public bool clear_tag (string tag);
-		public void clear_xmp ();
-		public void delete_gps_info ();
-		public void erase_exif_thumbnail ();
-		public bool from_app1_segment ([CCode (array_length = false)] uchar[] data, long n_data) throws GLib.Error;
-		public string? generate_xmp_packet (GExiv2.XmpFormatFlags xmp_format_flags, uint32 padding);
-		public string? get_comment ();
-		public bool get_exif_tag_rational (string tag, out int nom, out int den);
-		[CCode (array_length = false, array_null_terminated = true)]
-		public string[] get_exif_tags ();
-		public bool get_exif_thumbnail ([CCode (array_length_cname = "size", array_length_pos = 1.1)] out uint8[] buffer);
-		public bool get_exposure_time (out int nom, out int den);
-		public double get_fnumber ();
-		public double get_focal_length ();
-		public bool get_gps_altitude (out double altitude);
-		public bool get_gps_info (out double longitude, out double latitude, out double altitude);
-		public bool get_gps_latitude (out double latitude);
-		public bool get_gps_longitude (out double longitude);
-		[CCode (array_length = false, array_null_terminated = true)]
-		public string[] get_iptc_tags ();
-		public int get_iso_speed ();
-		public int get_metadata_pixel_height ();
-		public int get_metadata_pixel_width ();
-		public unowned string get_mime_type ();
-		public GExiv2.Orientation get_orientation ();
-		public int get_pixel_height ();
-		public int get_pixel_width ();
-		public GExiv2.PreviewImage get_preview_image (GExiv2.PreviewProperties props);
-		[CCode (array_length = false, array_null_terminated = true)]
-		public unowned GExiv2.PreviewProperties[]? get_preview_properties ();
-		public bool get_supports_exif ();
-		public bool get_supports_iptc ();
-		public bool get_supports_xmp ();
-		public static unowned string? get_tag_description (string tag);
-		public string? get_tag_interpreted_string (string tag);
-		public static unowned string? get_tag_label (string tag);
-		public long get_tag_long (string tag);
-		[CCode (array_length = false, array_null_terminated = true)]
-		public string[]? get_tag_multiple (string tag);
-		public GLib.Bytes? get_tag_raw (string tag);
-		public string? get_tag_string (string tag);
-		public static unowned string? get_tag_type (string tag);
-		public string? get_xmp_packet ();
-		[CCode (array_length = false, array_null_terminated = true)]
-		public string[] get_xmp_tags ();
-		public bool has_exif ();
-		public bool has_iptc ();
-		public bool has_tag (string tag);
-		public bool has_xmp ();
-		public static bool is_exif_tag (string tag);
-		public static bool is_iptc_tag (string tag);
-		public static bool is_xmp_tag (string tag);
-		public bool open_buf ([CCode (array_length = false)] uchar[] data, long n_data) throws GLib.Error;
-		public bool open_path (string path) throws GLib.Error;
-		public static bool register_xmp_namespace (string name, string prefix);
-		public bool save_file (string path) throws GLib.Error;
-		public void set_comment (string comment);
-		public bool set_exif_tag_rational (string tag, int nom, int den);
-		public void set_exif_thumbnail_from_buffer ([CCode (array_length_cname = "size", array_length_pos = 1.1)] uint8[] buffer);
-		public bool set_exif_thumbnail_from_file (string path) throws GLib.Error;
-		public bool set_gps_info (double longitude, double latitude, double altitude);
-		public void set_metadata_pixel_height (int height);
-		public void set_metadata_pixel_width (int width);
-		public void set_orientation (GExiv2.Orientation orientation);
-		public bool set_tag_long (string tag, long value);
-		public bool set_tag_multiple (string tag, [CCode (array_length = false, array_null_terminated = true)] string[] values);
-		public bool set_tag_string (string tag, string value);
-		public bool set_xmp_tag_struct (string tag, GExiv2.StructureType type);
-		public static void unregister_all_xmp_namespaces ();
-		public static bool unregister_xmp_namespace (string name);
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", type_id = "gexiv2_preview_image_get_type ()")]
-	public class PreviewImage : GLib.Object {
-		[CCode (has_construct_function = false)]
-		protected PreviewImage ();
-		[CCode (array_length_pos = 0.1, array_length_type = "guint32")]
-		public unowned uint8[] get_data ();
-		public unowned string get_extension ();
-		public uint32 get_height ();
-		public unowned string get_mime_type ();
-		public uint32 get_width ();
-		public long write_file (string path);
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", type_id = "gexiv2_preview_properties_get_type ()")]
-	public class PreviewProperties : GLib.Object {
-		[CCode (has_construct_function = false)]
-		protected PreviewProperties ();
-		public unowned string get_extension ();
-		public uint32 get_height ();
-		public unowned string get_mime_type ();
-		public uint32 get_size ();
-		public uint32 get_width ();
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cprefix = "GEXIV2_LOG_LEVEL_", has_type_id = false)]
-	public enum LogLevel {
-		DEBUG,
-		INFO,
-		WARN,
-		ERROR,
-		MUTE
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cprefix = "GEXIV2_ORIENTATION_", has_type_id = false)]
-	public enum Orientation {
-		MIN,
-		UNSPECIFIED,
-		NORMAL,
-		HFLIP,
-		ROT_180,
-		VFLIP,
-		ROT_90_HFLIP,
-		ROT_90,
-		ROT_90_VFLIP,
-		ROT_270,
-		MAX
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cprefix = "GEXIV2_STRUCTURE_XA_", has_type_id = false)]
-	public enum StructureType {
-		NONE,
-		ALT,
-		BAG,
-		SEQ,
-		LANG
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cprefix = "GEXIV2_", has_type_id = false)]
-	public enum XmpFormatFlags {
-		OMIT_PACKET_WRAPPER,
-		READ_ONLY_PACKET,
-		USE_COMPACT_FORMAT,
-		INCLUDE_THUMBNAIL_PAD,
-		EXACT_PACKET_LENGTH,
-		WRITE_ALIAS_COMMENTS,
-		OMIT_ALL_FORMATTING
-	}
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", has_target = false)]
-	public delegate void LogHandler (GExiv2.LogLevel level, string msg);
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cname = "GEXIV2_MAJOR_VERSION")]
-	public const int MAJOR_VERSION;
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cname = "GEXIV2_MICRO_VERSION")]
-	public const int MICRO_VERSION;
-	[CCode (cheader_filename = "gexiv2/gexiv2.h", cname = "GEXIV2_MINOR_VERSION")]
-	public const int MINOR_VERSION;
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public static int get_version ();
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public static bool initialize ();
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public static GExiv2.LogLevel log_get_level ();
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public static void log_set_level (GExiv2.LogLevel level);
-	[CCode (cheader_filename = "gexiv2/gexiv2.h")]
-	public static void log_use_glib_logging ();
-}
--- /dev/null
+++ b/m4/ax_check_enable_debug.m4
@@ -0,0 +1,124 @@
+# ===========================================================================
+#   http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
+#
+# DESCRIPTION
+#
+#   Check for the presence of an --enable-debug option to configure, with
+#   the specified default value used when the option is not present.  Return
+#   the value in the variable $ax_enable_debug.
+#
+#   Specifying 'yes' adds '-g -O0' to the compilation flags for all
+#   languages. Specifying 'info' adds '-g' to the compilation flags.
+#   Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
+#   the linking flags. Otherwise, nothing is added.
+#
+#   Define the variables listed in the second argument if debug is enabled,
+#   defaulting to no variables.  Defines the variables listed in the third
+#   argument if debug is disabled, defaulting to NDEBUG.  All lists of
+#   variables should be space-separated.
+#
+#   If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
+#   Should be invoked prior to any AC_PROG_* compiler checks.
+#
+#   IS-RELEASE can be used to change the default to 'no' when making a
+#   release.  Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
+#   uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
+#   macro, there is no need to pass this parameter.
+#
+#     AX_IS_RELEASE([git-directory])
+#     AX_CHECK_ENABLE_DEBUG()
+#
+# LICENSE
+#
+#   Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
+#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+#serial 5
+
+AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
+    AC_BEFORE([$0],[AC_PROG_CC])dnl
+    AC_BEFORE([$0],[AC_PROG_CXX])dnl
+    AC_BEFORE([$0],[AC_PROG_F77])dnl
+    AC_BEFORE([$0],[AC_PROG_FC])dnl
+
+    AC_MSG_CHECKING(whether to enable debugging)
+
+    ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
+    ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
+                                                              [$ax_is_release],
+                                                              [$4])))
+
+    # If this is a release, override the default.
+    AS_IF([test "$ax_enable_debug_is_release" = "yes"],
+      [ax_enable_debug_default="no"])
+
+    m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
+    m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
+
+    AC_ARG_ENABLE(debug,
+	[AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
+	[],enable_debug=$ax_enable_debug_default)
+
+    # empty mean debug yes
+    AS_IF([test "x$enable_debug" = "x"],
+      [enable_debug="yes"])
+
+    # case of debug
+    AS_CASE([$enable_debug],
+      [yes],[
+	AC_MSG_RESULT(yes)
+	CFLAGS="${CFLAGS} -g -O0"
+	CXXFLAGS="${CXXFLAGS} -g -O0"
+	FFLAGS="${FFLAGS} -g -O0"
+	FCFLAGS="${FCFLAGS} -g -O0"
+	OBJCFLAGS="${OBJCFLAGS} -g -O0"
+      ],
+      [info],[
+	AC_MSG_RESULT(info)
+	CFLAGS="${CFLAGS} -g"
+	CXXFLAGS="${CXXFLAGS} -g"
+	FFLAGS="${FFLAGS} -g"
+	FCFLAGS="${FCFLAGS} -g"
+	OBJCFLAGS="${OBJCFLAGS} -g"
+      ],
+      [profile],[
+	AC_MSG_RESULT(profile)
+	CFLAGS="${CFLAGS} -g -pg"
+	CXXFLAGS="${CXXFLAGS} -g -pg"
+	FFLAGS="${FFLAGS} -g -pg"
+	FCFLAGS="${FCFLAGS} -g -pg"
+	OBJCFLAGS="${OBJCFLAGS} -g -pg"
+	LDFLAGS="${LDFLAGS} -pg"
+      ],
+      [
+	AC_MSG_RESULT(no)
+	dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
+	dnl by setting any unset environment flag variables
+	AS_IF([test "x${CFLAGS+set}" != "xset"],
+	  [CFLAGS=""])
+	AS_IF([test "x${CXXFLAGS+set}" != "xset"],
+	  [CXXFLAGS=""])
+	AS_IF([test "x${FFLAGS+set}" != "xset"],
+	  [FFLAGS=""])
+	AS_IF([test "x${FCFLAGS+set}" != "xset"],
+	  [FCFLAGS=""])
+	AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
+	  [OBJCFLAGS=""])
+      ])
+
+    dnl Define various variables if debugging is disabled.
+    dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
+    AS_IF([test "x$enable_debug" = "xyes"],
+      [m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
+      [m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
+    ax_enable_debug=$enable_debug
+])
--- /dev/null
+++ b/test/gexiv2-regression.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 Jens Georg <mail@jensge.org>
+ *
+ * This library is free software. See COPYING for details
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+
+#include <gexiv2/gexiv2.h>
+
+#include <string.h>
+
+/* Check that gexiv2 correctly handles ratios with 0/0 as used by
+ * some cameras
+ */
+static void test_bgo_775249(void)
+{
+    GExiv2Metadata *meta = NULL;
+    gboolean result = FALSE;
+    gdouble lon = 0.0, lat = 0.0, alt = 0.0;
+    GError *error = NULL;
+
+    meta = gexiv2_metadata_new();
+    g_assert_nonnull(meta);
+    result = gexiv2_metadata_open_path(meta, SAMPLE_PATH "/CaorVN.jpeg", &error);
+    g_assert_no_error(error);
+    g_assert_true(result);
+    g_assert_true(gexiv2_metadata_get_gps_info(meta, &lon, &lat, &alt));
+
+    g_assert_cmpfloat(lon, ==, -1.508425);
+
+    /* Just check if it fits in there; The main issue is that it's not 0 */
+    g_assert_cmpfloat(lat, >=, 48.631806);
+    g_assert_cmpfloat(lat, <=, 48.631807);
+    g_assert_cmpfloat(alt, ==, -0.926000);
+
+    g_clear_object(&meta);
+}
+
+static const char test_bgo_730136_artist_data[] = {
+  0xc0, 0xeb, 0xe5, 0xea, 0xf1, 0xe0, 0xed, 0xe4,
+  0xf0,  ' ', 0xca, 0xee, 0xf8, 0xe5, 0xeb, 0xe5,
+  0xe2, 0x00
+};
+
+static void test_bgo_730136(void)
+{
+    GExiv2Metadata *meta = NULL;
+    gboolean result = FALSE;
+    GError *error = NULL;
+    GBytes *raw_tag = NULL;
+
+    meta = gexiv2_metadata_new ();
+    g_assert_nonnull (meta);
+    result = gexiv2_metadata_open_path (meta, SAMPLE_PATH "/sample-author-badencoding.jpg", &error);
+    g_assert_no_error(error);
+    g_assert_true(result);
+
+    raw_tag = gexiv2_metadata_get_tag_raw (meta, "Exif.Image.Artist");
+    g_assert_nonnull (raw_tag);
+    g_assert_cmpmem (g_bytes_get_data(raw_tag, NULL), g_bytes_get_size(raw_tag),
+                     test_bgo_730136_artist_data, sizeof(test_bgo_730136_artist_data));
+    g_clear_object (&meta);
+    g_clear_pointer (&raw_tag, g_bytes_unref);
+}
+
+int main(int argc, char *argv[static argc + 1])
+{
+    g_test_init(&argc, &argv, NULL);
+    g_test_add_func("/bugs/gnome/775249", test_bgo_775249);
+    g_test_add_func("/bugs/gnome/730136", test_bgo_730136);
+
+    return g_test_run();
+}
--- a/test/python/gexiv2.py
+++ b/test/python/gexiv2.py
@@ -31,6 +31,7 @@ gi.overrides.__path__.append(os.path.joi
                                           'gi', 'overrides'))
 
 
+gi.require_version('GExiv2', '0.10')
 from gi.repository import GExiv2
 
 
--- /dev/null
+++ b/test/python2-test.in
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+@PYTHON2_PATH@ -m unittest gexiv2
--- /dev/null
+++ b/test/python3-test.in
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+@PYTHON3_PATH@ -m unittest gexiv2
