How to use Drupal.behaviors in Drupal 7?
Probably to late to load the js file in the .tpl try in template.php with 

YOUR_THEME_preprocess_page(&amp;$variables) {
  if ($variables['is_front']) {
    drupal_add_js(drupal_get_path('theme', 'mythemename'). '/js/test.js');
  }
}