refactor test code
add test case 2 from rfc
add test 3 and 4 from rfc
fix tests