reorganized some utilities, fixed some tests