fix to badval fix (don't replace bads with nan until after limit calculation); update tests.