Made some tests to validade the code.
Found some problems and fixed them