Fix shift tests

Removed tests that relied on undefined behavior. Added some new tests that avoid test only defined behavior.
Also added some comments about the reason of these changes.

Adding notes to the documentation about these issues will come in a different pull request.