Added parameter checking and tests.