add tests for boundary conditions
and clean up code climate identified issues