Modified cat method with recursion. Added unit tests.