Better diagnostics
Fix tests