rolling back the removal of refine_data_type; aseem reports that it causes failures on simple examples; added a test case