How do I render contextual links for blocks I render in my code? I loaded a block subject and content with module_invoke() and used render() for rendering them. I want to use contextual links for this block. How can I render them too?

This is the code I am using insde the page--front.tpl.php template.

$block = module_invoke('block', 'block_view', '4);
print render($block);


What code should I instead use?
$block = block_load('module', 'delta');
print drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));


Too bad we have to use private functions from the block module (_*()) to achieve this.