Coprime Test

I read two numbers $a$ and $b$ are coprime if $b^{a - 1} = 1$ (mod a). Is it me or does this test not hold when a = 6 and b = 5, which are coprime?

$5^{6 - 1} = 1$ (mod 6)
$5^5 = 1$ (mod 6)
$3125 = 1$ (mod 6)

3125 mod 6 is 5, which does not equal 1, so the test fails. Is it me or the test?