Add comprehensive unit tests for Xdr, in preparation for refactorization