HTML:
Div 1 Div 2 Div 3 <
What you want to do is this:
$(".test").each(function(i) { alert(i); });
.index() returns the index relative to its siblings.