fix cast
More tests
Fix write-attribute transformer