Add bounds checking

Signed-off-by: John Else <john.else@citrix.com>
Add bounds checking tests

Signed-off-by: John Else <john.else@citrix.com>