refactor c
refactor c, make tests seperate