What exactly is the purpose of those $b_i$ terms?
$b_i = A^{2^i m} \bmod N$
If $\lambda$ is the number of times you divided by 2 in the first step, then $2^\lambda m = N-1$.
Hence, by Fermat's little theorem, if $b_\lambda \ne 1$, then we know $N$ is not prime (because $A^{N-1} = 1 \pmod N$ for any prime $N$, as long as $A$ is a not multiple of $N$). Hence, if you go $\lambda$ steps, and don't hit one, we know we have a composite.
At this point, we have two choises
Actually, you don't; you always perform $\lambda$ squarings unless you hit $N-1$ (actually, it turns out $\lambda-1$ is sufficient). That is, unless you hit 1 initially, or $N-1$ on any later step, we know $N$ is composite (either by Fermat's Last Theorem, or because nontrivial factors are deducible). We have to do that for the Miller-Rabin proof to hold (and anyways, that's a lot cheaper than picking another $A$ and computing $A^m$ all over again).
This is because if we have a value $B \ne 1, N-1$, and $B^2 = 1 \pmod N$, then $N$ is composite (and $\gcd(B-1, N), \gcd(B+1, N)$ are nontrivial factors). This (along with Fermat's little theorem) are why when MR says composite, it has proven it.