Add basic parameter checking and some tests