Code works but tests fail