Removed memory leaks and added testing for proper processing of numbers