Fixing bugs related to refactor, adding in test to debug against.