Fixed division by zero error
Added a unit test
Added parameter support