Added support for function variables, many new tests