improved nyquist() function

added testing and changed return values as suggested by rgommers and
ewmoore