Added modelmetadata test and fixed code to follow engineering guidelines