[#62667292] Added a test and cleaned up some code