Prevent panic when growing slices to a smaller size.

Added tests which would previously hit the panic.