diff --git a/fakeredis/_basefakesocket.py b/fakeredis/_basefakesocket.py
index 9929587..37259b4 100644
--- a/fakeredis/_basefakesocket.py
+++ b/fakeredis/_basefakesocket.py
@@ -7,7 +7,8 @@ from typing import List
 import redis
 
 from . import _msgs as msgs
-from ._commands import (Int, Float, SUPPORTED_COMMANDS, COMMANDS_WITH_SUB)
+from ._commands import (
+    Int, Float, SUPPORTED_COMMANDS, COMMANDS_WITH_SUB, key_value_type)
 from ._helpers import (
     SimpleError, valid_response_type, SimpleString, NoResponse, casematch,
     compile_pattern, QUEUED, encode_command)
@@ -295,7 +296,7 @@ class BaseFakeSocket:
 
         def match_type(key):
             if _type is not None:
-                return casematch(self._type(self._db[key]).value, _type)
+                return casematch(key_value_type(self._db[key]).value, _type)
             return True
 
         if pattern is not None or _type is not None:
diff --git a/fakeredis/_commands.py b/fakeredis/_commands.py
index cf751e1..00f2b06 100644
--- a/fakeredis/_commands.py
+++ b/fakeredis/_commands.py
@@ -7,7 +7,8 @@ import math
 import re
 
 from . import _msgs as msgs
-from ._helpers import null_terminate, SimpleError
+from ._helpers import null_terminate, SimpleError, SimpleString
+from ._zset import ZSet
 
 MAX_STRING_SIZE = 512 * 1024 * 1024
 SUPPORTED_COMMANDS = dict()  # Dictionary of supported commands name => Signature
@@ -414,3 +415,20 @@ def fix_range_string(start, end, length):
         end = max(0, end + length)
     end = min(end, length - 1)
     return start, end + 1
+
+
+def key_value_type(key):
+    if key.value is None:
+        return SimpleString(b'none')
+    elif isinstance(key.value, bytes):
+        return SimpleString(b'string')
+    elif isinstance(key.value, list):
+        return SimpleString(b'list')
+    elif isinstance(key.value, set):
+        return SimpleString(b'set')
+    elif isinstance(key.value, ZSet):
+        return SimpleString(b'zset')
+    elif isinstance(key.value, dict):
+        return SimpleString(b'hash')
+    else:
+        assert False  # pragma: nocover
diff --git a/fakeredis/commands_mixins/generic_mixin.py b/fakeredis/commands_mixins/generic_mixin.py
index 8517dae..e04cee8 100644
--- a/fakeredis/commands_mixins/generic_mixin.py
+++ b/fakeredis/commands_mixins/generic_mixin.py
@@ -3,8 +3,10 @@ import pickle
 from random import random
 
 from fakeredis import _msgs as msgs
-from fakeredis._commands import command, Key, Int, DbIndex, BeforeAny, CommandItem, SortFloat, delete_keys
-from fakeredis._helpers import compile_pattern, SimpleError, OK, casematch, SimpleString
+from fakeredis._commands import (
+    command, Key, Int, DbIndex, BeforeAny, CommandItem, SortFloat,
+    delete_keys, key_value_type, )
+from fakeredis._helpers import compile_pattern, SimpleError, OK, casematch
 from fakeredis._zset import ZSet
 
 
@@ -37,23 +39,6 @@ class GenericCommandsMixin:
                 return None
             return item.value
 
-    @staticmethod
-    def _key_value_type(key):
-        if key.value is None:
-            return SimpleString(b'none')
-        elif isinstance(key.value, bytes):
-            return SimpleString(b'string')
-        elif isinstance(key.value, list):
-            return SimpleString(b'list')
-        elif isinstance(key.value, set):
-            return SimpleString(b'set')
-        elif isinstance(key.value, ZSet):
-            return SimpleString(b'zset')
-        elif isinstance(key.value, dict):
-            return SimpleString(b'hash')
-        else:
-            assert False  # pragma: nocover
-
     def _expireat(self, key, timestamp, *args):
         nx = False
         xx = False
@@ -308,7 +293,7 @@ class GenericCommandsMixin:
 
     @command((Key(),))
     def type(self, key):
-        return self._key_value_type(key)
+        return key_value_type(key)
 
     @command((Key(),), (Key(),), name='unlink')
     def unlink(self, *keys):

diff --git a/test/test_mixins/test_generic_commands.py b/test/test_mixins/test_generic_commands.py
index 4987519..cf7a143 100644
--- a/test/test_mixins/test_generic_commands.py
+++ b/test/test_mixins/test_generic_commands.py
@@ -657,6 +657,7 @@ def test_scan_iter_single_page(r):
     assert set(r.scan_iter(match="foo*")) == {b'foo1', b'foo2'}
     assert set(r.scan_iter()) == {b'foo1', b'foo2'}
     assert set(r.scan_iter(match="")) == set()
+    assert set(r.scan_iter(match="foo1", _type="string")) == {b'foo1', }
 
 
 def test_scan_iter_multiple_pages(r):

AttributeError: 'FakeSocket' object has no attribute '_type'
**Describe the bug**
When calling `scan_iter` with `_type` as argument, it throws AttributeError.

**To Reproduce**

Minimal reproducible example:
```py
from fakeredis import FakeRedis
r = FakeRedis()
r.zadd("key", {"a": 2})
for _ in r.scan_iter(match="key", _type="ZSET"):
    pass
```
Trace:
```
Traceback (most recent call last):
  File "/mre/file.py", line 5, in <module>
    for _ in r.scan_iter(match="key", _type="ZSET"):
  File "/mre/.venv/lib/python3.10/site-packages/redis/commands/core.py", line 2939, in scan_iter
    cursor, data = self.scan(
  File "/mre/.venv/lib/python3.10/site-packages/redis/commands/core.py", line 2914, in scan
    return self.execute_command("SCAN", *pieces, **kwargs)
  File "/mre/.venv/lib/python3.10/site-packages/redis/client.py", line 1258, in execute_command
    return conn.retry.call_with_retry(
  File "/mre/.venv/lib/python3.10/site-packages/redis/retry.py", line 46, in call_with_retry
    return do()
  File "/mre/.venv/lib/python3.10/site-packages/redis/client.py", line 1259, in <lambda>
    lambda: self._send_command_parse_response(
  File "/mre/.venv/lib/python3.10/site-packages/redis/client.py", line 1234, in _send_command_parse_response
    conn.send_command(*args)
  File "/mre/.venv/lib/python3.10/site-packages/redis/connection.py", line 787, in send_command
    self.send_packed_command(
  File "/mre/.venv/lib/python3.10/site-packages/redis/connection.py", line 769, in send_packed_command
    self._sock.sendall(item)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 212, in sendall
    self._parser.send(data)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 123, in _parse_commands
    self._process_command(fields)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 240, in _process_command
    result = self._run_command(func, sig, cmd_arguments, False)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 144, in _run_command
    result = func(*args)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/commands_mixins/generic_mixin.py", line 206, in scan
    return self._scan(list(self._db), cursor, *args)
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 304, in _scan
    if match_key(compare_val) and match_type(compare_val):
  File "/mre/.venv/lib/python3.10/site-packages/fakeredis/_basefakesocket.py", line 298, in match_type
    return casematch(self._type(self._db[key]).value, _type)
AttributeError: 'FakeSocket' object has no attribute '_type'. Did you mean: 'type'?
```

**Expected behavior**
Filter the results for the expected `_type` without throwing errors.

**Desktop (please complete the following information):**
 - OS: macOS Monterey
 - python version: 3.10.8, but also reproduced it on 3.9.15
 - redis-py version: 4.4.0
 - fakeredis-py version: 2.3.0
 - full requirements.txt? Only `fakeredis`

test/test_mixins/test_generic_commands.py::test_scan_iter_single_page[FakeStrictRedis]
test/test_mixins/test_generic_commands.py::test_expireat_should_expire_key_by_datetime[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expireat_should_expire_key_by_timestamp[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expireat_should_return_true_for_existing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expireat_should_return_false_for_missing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_del_operator[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_not_handle_floating_point_values[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_ttl_should_return_minus_one_for_non_expiring_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_range_offset_range[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_range_offset_range_and_desc[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_range_offset_norange[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_range_with_large_range[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_descending[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_alpha[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_foo[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_empty[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_wrong_type[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_with_store_option[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_with_by_and_get_option[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_with_hash[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_sort_with_set[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_ttl_should_return_minus_two_for_non_existent_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_type[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_unlink[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_dump_missing[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_dump_restore[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_dump_restore_ttl[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_dump_restore_replace[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_restore_exists[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_restore_invalid_dump[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_restore_invalid_ttl[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_set_then_get[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_exists[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_expire_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_throw_error[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_extra_params_return_error[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_return_true_for_existing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_return_false_for_missing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_expire_key_using_timedelta[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_expire_immediately_with_millisecond_timedelta[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_watch_expire[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpire_should_expire_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpire_should_return_truthy_for_existing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpire_should_return_falsey_for_missing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpire_should_expire_key_using_timedelta[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpireat_should_expire_key_by_datetime[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpireat_should_expire_key_by_timestamp[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpireat_should_return_true_for_existing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pexpireat_should_return_false_for_missing_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pttl_should_return_minus_one_for_non_expiring_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_pttl_should_return_minus_two_for_non_existent_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_persist[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_watch_persist[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_set_existing_key_persists[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_set_non_str_keys[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_getset_not_exist[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_get_float_type[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_set_float_value[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_not_expire__when_no_expire_is_set[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_not_expire__when_expire_is_set[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_expire__when_expire_is_greater[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_expire_should_expire__when_expire_is_lessthan[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_rename[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_rename_nonexistent_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_renamenx_doesnt_exist[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_rename_does_exist[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_rename_expiry[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_keys[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_contains[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_delete[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_delete_expire[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_delete_multiple[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_delete_nonexistent_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_single[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_iter_multiple_pages[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_iter_multiple_pages_with_match[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_multiple_pages_with_count_arg[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_all_in_single_call[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_scan_expired_key[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_basic_sort[FakeStrictRedis] test/test_mixins/test_generic_commands.py::test_key_patterns[FakeStrictRedis]