small improvements to the utilts code

-only write to writable part of db
-extra check on set_int