Here's another answer. Assuming you mean test2 where you write test3, note that 'test2<5' is a logical vector. The minimum value will be FALSE. The maximum value (TRUE) is what you want:
> apply(test2<5,2,which.max)
[1] 3 4
Note that this is not correct if the maximum value is not TRUE.