Finished tests of custom functions and collapse argument
Fixed encoding into json when using a custom defined function