add tests and extend primitive function support