fix and test all methods in utils.c