avoid inconsistent usage of EncodedValue if double
test fixes; added tests