Bounds checks: add (failing) unit tests, then fix them