Fixes for variant type serialization and added a test

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>