Pregunta de entrevista de nShift

- improve the code by solving some redundant implementation - fix unit tests