fix operation order error in _spectral_helper and implement more tests to catch these sorts of problems in the future