Fixes in write-detector when using variable in 'unset'