Improve constant naming
Move validity test to common function
Mark encoding to return compatibility with 1.9.x

Incidentally, improve test title