s4-nbt: merge some fixes from samba3 nbt helper.