Improve type conversion function (fix #177) and fix failing tests from previous

The `tryCastType` function should be more strict and perform casting.
The `tryChangeType` function should be more flexible and allow both
casting and conversions using `IConvertible` interface. This fixes
`tryChangeType` to also allow casting (which was omitted earlier).