Code cleanup and added tests for problems 44, 45, 46