test: Factored out normalization code into normalize.py.
Reorganized code in spec_tests.py.