Fixed error on validation of certain contracts.

Added test case for regression.