added enc_varstr to encode variable length strings

also added tests for it.