improve with_mutex and with_mutex_if also

Signed-off-by: Mattias Andrée <maandree@operamail.com>