Fixes tests and undefined variable