The defaultargs attribute was not being correctly set for functions with default arguments when instantiated with %template. Closes #529