optimise scanning
Added mapRefs tests.
Flipped mapRefs to object pattern to allow deeper testing.