error with sex field corrected and tests improved