Changed the code to make it more simple, tests now work correctly