Fix boundary condition checking bug.

This handles the issue #38.