Extract common functionality to xblock-utils