improve error assertions in tests