Simplified and corrected bounds, unit test.