diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000000000000000000000000000000000..4d5d84092bfe590c4a69bb1ea1b4515f78bbea97
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.mat filter=lfs diff=lfs merge=lfs -text
diff --git a/matlab/missing/mex/local_state_space_iterations/local_state_space_iteration_2.m b/matlab/missing/mex/local_state_space_iterations/local_state_space_iteration_2.m
index 28c30f3f37c8a964745569ff80cde51b41323baf..db2255f4397343f2ab39a07b2efe15041d0c0ddd 100644
--- a/matlab/missing/mex/local_state_space_iterations/local_state_space_iteration_2.m
+++ b/matlab/missing/mex/local_state_space_iterations/local_state_space_iteration_2.m
@@ -1,4 +1,4 @@
-function [y, y_] = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, a, b, c)
+function [y, y_] = local_state_space_iteration_2(yhat, epsilon, ghx, ghu, constant, ghxx, ghuu, ghxu, a, b, c) % --*-- Unitary tests --*--
 
 % Given the demeaned states (yhat) and structural innovations (epsilon), this routine computes the level of selected endogenous variables when the
 % model is approximated by an order two taylor expansion around the deterministic steady state. Depending on the number of input/output
@@ -109,116 +109,103 @@ T = all(t);
 
 %@test:2
 old_path = pwd;
-cd([fileparts(which('dynare')) '/../tests/']);
-dynare('dsge_base2');
-load dsge_base2;
+cd([fileparts(which('dynare')) '/../tests/particle']);
+load dsgebase2data;
 cd(old_path);
-dr = oo_.dr;
-clear('oo_','options_','M_');
-delete([fileparts(which('dynare')) '/../tests/dsge_base2.mat']);
-istates = dr.nstatic+(1:dr.npred);
-n = dr.npred;
-q = size(dr.ghu,2);
-yhat = zeros(n,1);
-epsilon = zeros(q,1);
-ghx = dr.ghx(istates,:);
-ghu = dr.ghu(istates,:);
-constant = dr.ys(istates,:)+dr.ghs2(istates,:);
-ghxx = dr.ghxx(istates,:);
-ghuu = dr.ghuu(istates,:);
-ghxu = dr.ghxu(istates,:);
-yhat_ = zeros(n,1);
-ss = dr.ys(istates,:);
-
-t = ones(2,1);
-
-% Call the tested routine.
+n = length(state_variables_idx);
+q = size(ReducedForm.ghu,2);
+yhatinit = randn(n,1);
+epsilon = randn(q,2);
+ghx = ReducedForm.ghx(state_variables_idx,:);
+ghu = ReducedForm.ghu(state_variables_idx,:);
+constant = ReducedForm.constant(state_variables_idx,:);
+ghxx = ReducedForm.ghxx(state_variables_idx,:);
+ghuu = ReducedForm.ghuu(state_variables_idx,:);
+ghxu = ReducedForm.ghxu(state_variables_idx,:);
+yhatinit_ = randn(n,1);
+ss = ReducedForm.state_variables_steady_state;
+t = true(6,1);
+% Call the tested routine (matlab).
+addpath(sprintf('%s/missing/mex/local_state_space_iterations', fileparts(which('dynare'))))
 try
-    y1 = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1);
+    yhat1 = local_state_space_iteration_2(yhatinit, epsilon(:,1), ghx, ghu, constant, ghxx, ghuu, ghxu, 1);
+    yhat1 = local_state_space_iteration_2(yhat1, epsilon(:,2), ghx, ghu, constant, ghxx, ghuu, ghxu, 1);
 catch
-    t(1) = 0;
+    t(1) = false;
 end
 try
-    [y2,y2_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,ss,1);
+    [yhat2, yhat2_] = local_state_space_iteration_2(yhatinit, epsilon(:,1), ghx, ghu, constant, ghxx, ghuu, ghxu, yhatinit_, ss, 1);
+    [yhat2, yhat2_] = local_state_space_iteration_2(yhat2, epsilon(:,2), ghx, ghu, constant, ghxx, ghuu, ghxu, yhat2_, ss, 1);
 catch
-    t(2) = 0;
+    t(2) = false;
 end
-
-% Check the results.
+rmpath(sprintf('%s/missing/mex/local_state_space_iterations', fileparts(which('dynare'))))
+% Call the tested routine (mex).
+try
+    yhat3 = local_state_space_iteration_2(yhatinit, epsilon(:,1), ghx, ghu, constant, ghxx, ghuu, ghxu, 1);
+    yhat3 = local_state_space_iteration_2(yhat3, epsilon(:,2), ghx, ghu, constant, ghxx, ghuu, ghxu, 1);
+catch
+    t(3) = false;
+end
+try
+    [yhat4, yhat4_] = local_state_space_iteration_2(yhatinit, epsilon(:,1), ghx, ghu, constant, ghxx, ghuu, ghxu, yhatinit_, ss, 1);
+    [yhat4, yhat4_] = local_state_space_iteration_2(yhat4, epsilon(:,2), ghx, ghu, constant, ghxx, ghuu, ghxu, yhat4_, ss, 1);
+catch
+    t(4) = false;
+end
+t(5) = max(abs(yhat1-yhat3))<1e-10; % Compare matlab and mex routines without pruning.
+t(6) = max(abs(yhat2-yhat4))<1e-10; % Compare matlab and mex routines with pruning. 
+                                    % Check the results.
 T = all(t);
 %@eof:2
 
 %@test:3
-Bohrbug = 1; % A bug that manifests reliably under a possibly unknown but well-defined set of conditions.
-if ~Bohrbug
-    n = 2;
-    q = 3;
-
-    yhat = .01*randn(n,1);
-    epsilon = .001*randn(q,1);
-    ghx = rand(n,n);
-    ghu = rand(n,q);
-    constant = ones(n,1);
-    ghxx = rand(n,n*n);
-    ghuu = rand(n,q*q);
-    ghxu = rand(n,n*q);
-    yhat_ = zeros(n,1);
-    ss = ones(n,1);
-
-    % Call the tested routine (mex version).
-    y1a = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1);
-    [y2a,y2a_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,ss,1);
-
-    % Call the tested routine (matlab version)
-    path_to_mex = fileparts(which(['qmc_sequence.' mexext]));
-    where_am_i_coming_from = pwd;
-    cd(path_to_mex);
-    tar('local_state_space_iteration_2.tar',['local_state_space_iteration_2.' mexext]);
-    cd(where_am_i_coming_from);
-    dynare_config();
-    y1b = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1);
-    [y2b,y2b_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,ss,1);
-    cd(path_to_mex);
-    untar('local_state_space_iteration_2.tar');
-    delete('local_state_space_iteration_2.tar');
-    cd(where_am_i_coming_from);
-    dynare_config();
-    % Check the results.
-    t(1) = dassert(y1a,y1b);
-    t(2) = dassert(y2a,y2b);
-    t(3) = dassert(y2a_,y2b_);
-    T = all(t);
-else
-    t(1) = 1;
-    T = all(t);
-end
+n = 2;
+q = 3;
+yhat = .01*randn(n,1);
+epsilon = .001*randn(q,1);
+ghx = rand(n,n);
+ghu = rand(n,q);
+constant = ones(n,1);
+ghxx = rand(n,n*n);
+ghuu = rand(n,q*q);
+ghxu = rand(n,n*q);
+yhat_ = zeros(n,1);
+ss = ones(n,1);
+% Call the tested routine (mex version).
+y1a = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1);
+[y2a,y2a_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,ss,1);
+% Call the tested routine (matlab version)
+addpath(sprintf('%s/missing/mex/local_state_space_iterations', fileparts(which('dynare'))))
+y1b = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1);
+[y2b,y2b_] = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,yhat_,ss,1);
+rmpath(sprintf('%s/missing/mex/local_state_space_iterations', fileparts(which('dynare'))))
+% Check the results.
+t(1) = max(abs(y1a-y1b))<1e-6;
+t(2) = max(abs(y2a-y2b))<1e-6;
+t(3) = max(abs(y2a_-y2b_))<1e-6;
+T = all(t);
 %@eof:3
 
-
 %@test:4
 % TIMING TEST (parallelization with openmp)
 old_path = pwd;
-cd([fileparts(which('dynare')) '/../tests/']);
-dynare('dsge_base2');
-load dsge_base2;
+cd([fileparts(which('dynare')) '/../tests/particle']);
+load dsgebase2data;
 cd(old_path);
-dr = oo_.dr;
-clear('oo_','options_','M_');
-delete([fileparts(which('dynare')) '/../tests/dsge_base2.mat']);
-istates = dr.nstatic+(1:dr.npred);
-n = dr.npred;
-q = size(dr.ghu,2);
-yhat = zeros(n,10000000);
-epsilon = zeros(q,10000000);
-ghx = dr.ghx(istates,:);
-ghu = dr.ghu(istates,:);
-constant = dr.ys(istates,:)+dr.ghs2(istates,:);
-ghxx = dr.ghxx(istates,:);
-ghuu = dr.ghuu(istates,:);
-ghxu = dr.ghxu(istates,:);
-yhat_ = zeros(n,10000000);
-ss = dr.ys(istates,:);
-
+n = length(state_variables_idx);
+q = size(ReducedForm.ghu,2);
+yhat = randn(n,10000000);
+epsilon = .01*randn(q,10000000);
+ghx = ReducedForm.ghx(state_variables_idx,:);
+ghu = ReducedForm.ghu(state_variables_idx,:);
+constant = ReducedForm.constant(state_variables_idx,:);
+ghxx = ReducedForm.ghxx(state_variables_idx,:);
+ghuu = ReducedForm.ghuu(state_variables_idx,:);
+ghxu = ReducedForm.ghxu(state_variables_idx,:);
+yhatinit_ = randn(n,1);
+ss = ReducedForm.state_variables_steady_state;
+yhat_ = randn(n,10000000);
 t = NaN(4,1);
 tic, for i=1:10, y1 = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,1); end
 t1 = toc;
@@ -238,4 +225,4 @@ if ~t(4)
 end
 % Check the results.
 T = all(t);
-%@eof:4
+%@eof:4
\ No newline at end of file
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 864b0f9fdb53420dd1ead9b448511f734ee5414f..e532bc68bf1d13171f35d8ce71140729231f1ff6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1307,6 +1307,7 @@ EXTRA_DIST = \
 	smoother2histval/fsdat_simul.m \
 	particle/first_spec_common.inc \
 	particle/risky.m \
+	particle/dsgebase2data.mat \
 	optimal_policy/Ramsey/find_c.m \
 	observation_trends_and_prefiltering/generate_trend_stationary_AR1.m \
 	observation_trends_and_prefiltering/Trend_diagnostics_MCMC_common.inc \
diff --git a/tests/analytic_derivatives/nBrockMirmanSYM.mat b/tests/analytic_derivatives/nBrockMirmanSYM.mat
index 7bdc38ac0d54728900867927b11d59e5c88a32dc..113a48a912ee78924d859e4fe8a6812dd3bd7498 100644
Binary files a/tests/analytic_derivatives/nBrockMirmanSYM.mat and b/tests/analytic_derivatives/nBrockMirmanSYM.mat differ
diff --git a/tests/block_bytecode/lola_data.mat b/tests/block_bytecode/lola_data.mat
index 67c0c926c8df9a32565bdd42493f71cd3a889163..e74ec24ea785253402065f0a6932cad25e3b650b 100644
Binary files a/tests/block_bytecode/lola_data.mat and b/tests/block_bytecode/lola_data.mat differ
diff --git a/tests/decision_rules/example1_results_dyn_432.mat b/tests/decision_rules/example1_results_dyn_432.mat
index 9674ccf0d77cbaeabf81220e3445a3164017cee0..13f800b12ef0a2354928a9d6f665ded14c85eba3 100644
Binary files a/tests/decision_rules/example1_results_dyn_432.mat and b/tests/decision_rules/example1_results_dyn_432.mat differ
diff --git a/tests/decision_rules/third_order/FV_2011_policyfunctions.mat b/tests/decision_rules/third_order/FV_2011_policyfunctions.mat
index 40d30f764b4eb86df57e2e397d8b019c6a82ae56..2135366e2039e38b570dca7187babc9240ba27bb 100644
Binary files a/tests/decision_rules/third_order/FV_2011_policyfunctions.mat and b/tests/decision_rules/third_order/FV_2011_policyfunctions.mat differ
diff --git a/tests/estimation/method_of_moments/AFVRR/AFVRR_data.mat b/tests/estimation/method_of_moments/AFVRR/AFVRR_data.mat
index f606b2109e2bf61024b860d13000842c27f3d290..d14be4caa39cccb4d9aab8f9e11216320b79c0b9 100644
Binary files a/tests/estimation/method_of_moments/AFVRR/AFVRR_data.mat and b/tests/estimation/method_of_moments/AFVRR/AFVRR_data.mat differ
diff --git a/tests/estimation/method_of_moments/AnScho/AnScho_MoM_data_2.mat b/tests/estimation/method_of_moments/AnScho/AnScho_MoM_data_2.mat
index bce9e7d36c9cbd41c1a9e1cd230ba71c109df886..e27910992638b7d002043af0a1da9aa854d558f7 100644
Binary files a/tests/estimation/method_of_moments/AnScho/AnScho_MoM_data_2.mat and b/tests/estimation/method_of_moments/AnScho/AnScho_MoM_data_2.mat differ
diff --git a/tests/estimation/method_of_moments/RBC/RBC_Andreasen_Data_2.mat b/tests/estimation/method_of_moments/RBC/RBC_Andreasen_Data_2.mat
index 0b2ba62defdaab77aa663f2907ae16801837f6b6..a2faf16f905da9e21f3f9e031d7bf6d5f5263ef0 100644
Binary files a/tests/estimation/method_of_moments/RBC/RBC_Andreasen_Data_2.mat and b/tests/estimation/method_of_moments/RBC/RBC_Andreasen_Data_2.mat differ
diff --git a/tests/gsa/data_ca1.mat b/tests/gsa/data_ca1.mat
index de3fc44b2782816040625d184ccccddd42c6658d..0531f72221968e4ac2705c0eeaaad811c8a0474d 100644
Binary files a/tests/gsa/data_ca1.mat and b/tests/gsa/data_ca1.mat differ
diff --git a/tests/identification/as2007/G_QT.mat b/tests/identification/as2007/G_QT.mat
index 74b7e73992fe5b7efc757fc93bddce5bd2aa4ad0..170b7c0cfe628f865ebf0fed8d124c07c1c9e1d3 100644
Binary files a/tests/identification/as2007/G_QT.mat and b/tests/identification/as2007/G_QT.mat differ
diff --git a/tests/kalman_filter_smoother/test.mat b/tests/kalman_filter_smoother/test.mat
index 95db1c32c5e5181af8588cbd8421672a2748aa76..2a325d4347285b1b1c7516efade3fc8c101abab4 100644
Binary files a/tests/kalman_filter_smoother/test.mat and b/tests/kalman_filter_smoother/test.mat differ
diff --git a/tests/kronecker/nash_matrices.mat b/tests/kronecker/nash_matrices.mat
index 530c7e4ebb3cc540c58d0af534bafe31de80ff46..0e122960ebadb93094b1e7e765b442ebc81b4ad4 100644
Binary files a/tests/kronecker/nash_matrices.mat and b/tests/kronecker/nash_matrices.mat differ
diff --git a/tests/objectives/sgu_ex1.mat b/tests/objectives/sgu_ex1.mat
index 69413985099ccb48f898c4ba4808132bda33c23e..5f7a3b3dde42fbe9c399ee925b4df7a630f69b3b 100644
Binary files a/tests/objectives/sgu_ex1.mat and b/tests/objectives/sgu_ex1.mat differ
diff --git a/tests/occbin/filter/NKM_mh_mode_saved.mat b/tests/occbin/filter/NKM_mh_mode_saved.mat
index 80764521cd915b366960d91fe4c93cdbbf481a72..fa8e685b5a3a7db4ef103975db41f92195bb7e33 100644
Binary files a/tests/occbin/filter/NKM_mh_mode_saved.mat and b/tests/occbin/filter/NKM_mh_mode_saved.mat differ
diff --git a/tests/occbin/filter/dataobsfile.mat b/tests/occbin/filter/dataobsfile.mat
index 93b6334ad748cab20233647ef9a951975b26b9aa..c7932d9a44818eb8707c2d06b6f21465449c9ce7 100644
Binary files a/tests/occbin/filter/dataobsfile.mat and b/tests/occbin/filter/dataobsfile.mat differ
diff --git a/tests/particle/dsgebase2data.mat b/tests/particle/dsgebase2data.mat
new file mode 100644
index 0000000000000000000000000000000000000000..a018a69336f9a13eec0d98893352669f82a1e416
--- /dev/null
+++ b/tests/particle/dsgebase2data.mat
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a1fe5c7ae3cdcabc3b1c9d2c3030d7b055b29e0edc2d4e7d8d9c9926cf4e5734
+size 904
diff --git a/tests/pruning/Andreasen_et_al_2018_Dynare44Pruning_v2.mat b/tests/pruning/Andreasen_et_al_2018_Dynare44Pruning_v2.mat
index 7bfbab5827dfc26b3676e694d2dc508f6b956b40..2bf2e03ba59522881a5b378994d2522914f5b763 100644
Binary files a/tests/pruning/Andreasen_et_al_2018_Dynare44Pruning_v2.mat and b/tests/pruning/Andreasen_et_al_2018_Dynare44Pruning_v2.mat differ
diff --git a/tests/shock_decomposition/example1_calib_shock_decomp_data.mat b/tests/shock_decomposition/example1_calib_shock_decomp_data.mat
index a5ecea5bb361b8c8960ce320b79fabfe2f478a0e..7fb4509f966e73238891ad3966f67f1e7cd43628 100644
Binary files a/tests/shock_decomposition/example1_calib_shock_decomp_data.mat and b/tests/shock_decomposition/example1_calib_shock_decomp_data.mat differ