Add and refactor functions; refactor testing approach