Extract common functionality to xblock-utils

+1 to @antoviaque note