Refactoring Test and adding tests for ArrayList too.