More perf improvements by reducing allocation.

Moved tests into their own module to reduce compilation time when
running benchmarks.