added length conversion code and 2 tests