Fixed bug where bounds were not properly applied.
Added test case.