Refactored code and fixed a bug

Moved the function to a folder so that tests will fit;
Removed output from the function file;
Fixed a bug - now depth can also be negative.