Fix check on empty body in serialization