Cleanup comments
Improved function and variable names
Fixed error in calculating p-value
Added input checks.
Improved docstrings. Added descriptions, return values, etc.