Fix handling of non-encodable types (boolean) and add test