fixed issue serializing unions.
added minimal test script