Get post by Category in custom template

<?php
$categories=get_categories('');
foreach($categories as $category) { 
    echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
    echo '<p> Cat ID: '. $category->cat_ID. '</p>';

    // The Query
    $id_cat = $category->cat_ID;
    $args = array(
        'cat' =>  $id_cat,
        'showposts' => 5,
    );
    query_posts( $args );

    // The Loop
    while ( have_posts() ) : the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;
}

// Reset Query
wp_reset_query();