refactored dynArray functions and added tests