Refactor AutofunkEngine by splitting methods

Update tests accordingly