Cleaned up solution 12 and added a test case.