fixed memory errors and added 5th test