This did the trick.
(defun jarfar/org-update-all-statistics-cookies ()
"Update all statistics cookies in org buffer."
(when (string-equal major-mode "org-mode")
(add-hook 'buffer-list-update-hook 'jarfar/org-update-all-statistics-cookies)
(advice-add 'save-buffer :before (lambda (&rest args) (jarfar/org-update-all-statistics-cookies)))
Sadly this messes things up.
When cookies get updated the file is marked as modified even if there were no changes, so it cause constant problems with unsaved changes.
It turned out that it's better to refresh cookies manually.