Added weighted residual method and unit test