I couldn't find tests on this code, am I missing something? It looks kind of complex