nShift Interview Question

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