fix leak, add test, for #33