diff --git a/tests/Makefile.am b/tests/Makefile.am
index 81619c23851fc83941f9e14db68ff98558cc2dbe..2913461ca284728d38002e92bee7442d70423a14 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
 MODFILES = \
-	walsh.mod \
+	first_order/walsh.mod \
 	occbin/model_irrcap_twoconstraints/dynrbc.mod \
 	occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.mod \
 	occbin/model_borrcon/borrcon.mod \
@@ -97,29 +97,26 @@ MODFILES = \
 	gsa/ls2003.mod \
 	gsa/cod_ML_morris/cod_ML_morris.mod \
 	gsa/morris/nk_est.mod \
-	ramst.mod \
-	ramst_a.mod \
-	ramst_static_tag.mod \
-	ramst_static_tag_block.mod \
-	ramst_mshocks.mod \
-	ramst_model_edit.mod \
+	simul/ramst.mod \
+	simul/ramst_a.mod \
+	simul/ramst_mshocks.mod \
+	simul/ramst_mshocks_vec.mod \
 	on-the-fly/ex1.mod \
 	on-the-fly/ex2.mod \
 	on-the-fly/ex3.mod \
 	on-the-fly/ex4.mod \
 	on-the-fly/ex5.mod \
 	on-the-fly/ex6.mod \
-	example1.mod \
-	example2.mod \
-	example1_use_dll.mod \
-	example1_with_tags.mod \
-	example1_irf_shocks.mod \
-	example1_abs_sign.mod \
-	example1_mlv.mod \
-	example1long.mod \
-	example2long.mod \
-	example2long_use_dll.mod \
-	t_sgu_ex1.mod \
+	equation_tags/example1_with_tags.mod \
+	equation_tags/ramst_static_tag.mod \
+	equation_tags/ramst_static_tag_block.mod \
+	stochastic_simulations/example1_irf_shocks.mod \
+	stochastic_simulations/example1long.mod \
+	stochastic_simulations/example2long.mod \
+	stochastic_simulations/example2long_use_dll.mod \
+	stochastic_simulations/example2_simul_replic.mod \
+	stochastic_simulations/histval_sto.mod \
+	stochastic_simulations/histval_predetermined.mod \
 	macro_processor/test_ifndef.mod \
 	macro_processor/example1_macro.mod \
 	irfs/example1_unit_std.mod \
@@ -163,18 +160,15 @@ MODFILES = \
 	histval_initval_file/ramst_datafile.mod \
 	histval_initval_file/sim_exo_lead_lag.mod \
 	histval_initval_file/sim_exo_lead_lag_initvalf.mod \
-	ramst_normcdf_and_friends_mfile.mod \
-	ramst_normcdf_and_friends_use_dll.mod \
-	ramst_normcdf_and_friends_bytecode.mod \
-	ramst_vec.mod \
-	ramst_mshocks_vec.mod \
-	example1_varexo_det.mod \
-	predetermined_variables.mod \
-	fs2000_ssfile.mod \
-	comments.mod \
-	histval_sto.mod \
-	histval_det.mod \
-	histval_predetermined.mod \
+	stat_functions/ramst_normcdf_and_friends_mfile.mod \
+	stat_functions/ramst_normcdf_and_friends_use_dll.mod \
+	stat_functions/ramst_normcdf_and_friends_bytecode.mod \
+	stat_functions/example1_abs_sign.mod \
+	simul/predetermined_variables.mod \
+	simul/histval_det.mod \
+	preprocessor_checks/comments.mod \
+	preprocessor_checks/example1_mlv.mod \
+	preprocessor_checks/ramst_model_edit.mod \
 	auxiliary_variables/test1.mod \
 	expectations/expectation.mod \
 	expectations/expectation_ss.mod \
@@ -189,6 +183,7 @@ MODFILES = \
 	steady_state/example1_block_trust_region.mod \
 	steady_state/Gali_2015_chapter_6_4.mod \
 	steady_state/ramst_solve_algo_0.mod \
+	steady_state/fs2000_ssfile.mod \
 	steady_state_operator/standard.mod \
 	steady_state_operator/use_dll.mod \
 	steady_state_operator/block.mod \
@@ -256,7 +251,6 @@ MODFILES = \
 	external_function/no_deriv_given.mod \
 	external_function/no_deriv_given_dll.mod \
 	external_function/extfun_in_mlv.mod \
-	seeds.mod \
 	minimal_state_space_system/as2007_minimal.mod \
 	minimal_state_space_system/sw_minimal.mod \
 	identification/kim/kim2.mod \
@@ -274,7 +268,9 @@ MODFILES = \
 	identification/correlated_errors/fs2000_corr.mod \
 	identification/forward_looking/forward_looking_empty_ghx.mod \
 	identification/forward_looking/forward_looking_varobs_x.mod \
+	model_diagnostics/example2_block_model_diag.mod	\
 	simul/example1.mod \
+	simul/ramst_vec.mod \
 	simul/Solow_no_varexo.mod \
 	simul/simul_ZLB_purely_forward.mod \
 	simul/simul_ZLB_purely_forward_no_solution.mod \
@@ -361,6 +357,7 @@ MODFILES = \
 	ep/rbc_bytecode.mod \
 	ep/rbcii_MCP.mod \
 	stochastic_simulations/example1_noprint.mod \
+	stochastic_simulations/example_seeds.mod \
 	stochastic-backward-models/solow_cd.mod \
 	stochastic-backward-models/solow_ces.mod \
 	stochastic-backward-models/solow_cd_with_steadystate.mod \
@@ -407,6 +404,7 @@ MODFILES = \
 	trend_var/fs2000_log_nonstationary.mod \
 	decision_rules/third_order/FV2011.mod \
 	decision_rules/example1.mod \
+	decision_rules/example1_use_dll.mod \
 	decision_rules/ar_qz_test.mod \
 	shock_decomposition/example1_calib_shock_decomp.mod \
 	shock_decomposition/fs2000_est.mod \
@@ -416,6 +414,7 @@ MODFILES = \
 	shock_decomposition/shock_decomp_backward.mod \
 	stochastic_purely_forward/stochastic_purely_forward.mod \
 	stochastic_purely_forward/stochastic_purely_forward_with_static.mod \
+	forecast/example1_varexo_det.mod \
 	forecast/Hansen_exo_det_forecast.mod \
 	forecast/linear_exo_det_forecast.mod \
 	forecast/ls2003_rolling_window_forecast.mod \
@@ -675,8 +674,9 @@ PARTICLEFILES = \
 	particle/local_state_space_iteration_3_test.mod
 
 
-XFAIL_MODFILES = ramst_xfail.mod \
-	estim_param_in_shock_value_xfail.mod \
+XFAIL_MODFILES = preprocessor_checks/ramst_all_values_required_xfail.mod \
+	preprocessor_checks/example1_undeclared_vars_xfail.mod \
+	estimation/estim_param_in_shock_value_xfail.mod \
 	optimal_policy/Ramsey/ramsey_ex_wrong_ss_file_xfail.mod \
 	estimation/fs2000_mixed_ML_xfail.mod \
 	estimation/fs2000_stochastic_singularity_xfail.mod \
@@ -690,7 +690,7 @@ XFAIL_MODFILES = ramst_xfail.mod \
 	particle/first_spec_xfail_0.mod \
 	particle/first_spec_xfail_1.mod \
 	kalman_initial_state/fs2000_kalman_initial_xfail.mod \
-	example1_extra_exo_xfail.mod \
+	preprocessor_checks/example1_extra_exo_xfail.mod \
 	estimation/tune_mh_jscale/fs2000_1_xfail.mod \
 	estimation/tune_mh_jscale/fs2000_2_xfail.mod \
 	estimation/no_init_estimation_check_first_obs/fs2000_init_check_XFAIL.mod \
@@ -717,14 +717,14 @@ occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.o.trs: occbin/model_irrca
 occbin/model_borrcon/borrcon_0_std_shocks.m.trs: occbin/model_borrcon/borrcon.m.trs
 occbin/model_borrcon/borrcon_0_std_shocks.o.trs: occbin/model_borrcon/borrcon.o.trs
 
-example1_use_dll.m.trs: example1.m.trs
-example1_use_dll.o.trs: example1.o.trs
+decision_rules/example1_use_dll.m.trs: decision_rules/example1.m.trs
+decision_rules/example1_use_dll.o.trs: decision_rules/example1.o.trs
 
-example2long_use_dll.m.trs: example1long.m.trs
-example2long_use_dll.o.trs: example1long.o.trs
+stochastic_simulations/example2long_use_dll.m.trs: stochastic_simulations/example1long.m.trs
+stochastic_simulations/example2long_use_dll.o.trs: stochastic_simulations/example1long.o.trs
 
-example2long.m.trs: example1long.m.trs
-example2long.o.trs: example1long.o.trs
+stochastic_simulations/example2long.m.trs: stochastic_simulations/example1long.m.trs
+stochastic_simulations/example2long.o.trs: stochastic_simulations/example1long.o.trs
 
 estimation/MH_recover/fs2000_recover_tarb.m.trs: estimation/MH_recover/fs2000_recover.m.trs
 estimation/MH_recover/fs2000_recover_tarb.o.trs: estimation/MH_recover/fs2000_recover.o.trs
@@ -869,8 +869,8 @@ deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.o.trs: determ
 deterministic_simulations/multiple_lead_lags/sim_lead_lag.m.trs: deterministic_simulations/multiple_lead_lags/sim_base.m.trs deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.m.trs
 deterministic_simulations/multiple_lead_lags/sim_lead_lag.o.trs: deterministic_simulations/multiple_lead_lags/sim_base.o.trs deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.o.trs
 
-deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.m.trs: ramst.m.trs
-deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.o.trs: ramst.o.trs
+deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.m.trs: simul/ramst.m.trs
+deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.o.trs: simul/ramst.o.trs
 
 loglinear/example4_loglinear.m.trs: loglinear/example4_exp.m.trs
 loglinear/example4_loglinear.o.trs: loglinear/example4_exp.o.trs
@@ -984,11 +984,11 @@ particle/local_it_k_test_parallel.o.trs: particle/first_spec.o.trs
 pruning/AS_pruned_state_space_red_shock.m.trs: pruning/AnSchorfheide_pruned_state_space.m.trs
 pruning/AS_pruned_state_space_red_shock.o.trs: pruning/AnSchorfheide_pruned_state_space.o.trs
 
-ramst_model_edit.m.trs: ramst.m.trs
-ramst_model_edit.o.trs: ramst.o.trs
+preprocessor_checks/ramst_model_edit.m.trs: simul/ramst.m.trs
+preprocessor_checks/ramst_model_edit.o.trs: simul/ramst.o.trs
 
-log_transform/ramst.m.trs: ramst.m.trs
-log_transform/ramst.o.trs: ramst.o.trs
+log_transform/ramst.m.trs: simul/ramst.m.trs
+log_transform/ramst.o.trs: simul/ramst.o.trs
 
 model-inversion/nk-1/invert.m.trs: model-inversion/nk-1/simulate.m.trs
 model-inversion/nk-1/invert.o.trs: model-inversion/nk-1/simulate.o.trs
@@ -1305,7 +1305,7 @@ EXTRA_DIST = \
 	run_reporting_test_matlab.m \
 	run_reporting_test_octave.m \
 	run_all_unit_tests.m \
-	+matlab/+namespace/y_k.m \
+	first_order/+matlab/+namespace/y_k.m \
 	reporting/AnnualTable.m \
 	reporting/CommResidTablePage.m \
 	reporting/CountryGraphPage.m \
@@ -1318,7 +1318,7 @@ EXTRA_DIST = \
 	reporting/runDynareReport.m \
 	homotopy/common.mod \
 	block_bytecode/ls2003.mod \
-	fs2000_ssfile_aux.m \
+	steady_state/fs2000_ssfile_aux.m \
 	utils/printMakeCheckMatlabErrMsg.m \
 	utils/printMakeCheckOctaveErrMsg.m \
 	utils/fataltest.m \
@@ -1352,7 +1352,6 @@ EXTRA_DIST = \
 	measurement_errors/data_ca1.m \
 	measurement_errors/fs2000_corr_me_ml_mcmc/fsdat_simul.m \
 	missing/simulate_data_with_missing_observations.m \
-	objectives/sgu_ex1.mat \
 	conditional_forecasts/2/fsdat_simul.m \
 	ms-sbvar/msdata.m \
 	ms-sbvar/archive-files/ftd_2s_caseall_upperchol3v.m \
@@ -1483,7 +1482,7 @@ EXTRA_DIST = \
 	solver-test-functions/variablydimensioned.m \
 	solver-test-functions/watson.m \
 	solver-test-functions/wood.m \
-	ramst_normcdf_and_friends.inc \
+	stat_functions/ramst_normcdf_and_friends.inc \
 	solve_algo_12_14/backward_model.inc \
 	solve_algo_12_14/simul_backward_common.inc \
 	solve_algo_12_14/purely_backward_common.inc \
@@ -1611,7 +1610,6 @@ clean-local:
 	rm -f $(shell find -name H.dat)
 
 	rm -f arima/data1.m arima/data2.m \
-		k_order_perturbation/*.jnl \
 		k_order_perturbation/*.mat \
 		kalman_filter_smoother/data_algo.mat \
 		kalman_filter_smoother/data_Pinf_Pstar.mat
diff --git a/tests/example1_use_dll.mod b/tests/decision_rules/example1_use_dll.mod
similarity index 100%
rename from tests/example1_use_dll.mod
rename to tests/decision_rules/example1_use_dll.mod
diff --git a/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod b/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
index fe6e9ae2d4fcadb1be1301ed252301963dfed6c3..76aa3c147a92ccc7ed7c3c212f5cf09d6bb49ce0 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
@@ -71,7 +71,7 @@ if max(abs(junk(M_.maximum_lag+1:end)-oo_.endo_simul(strmatch('y_backward',M_.en
     error('Solution of purely backwards model not correct')
 end
         
-ramst_results=load('../../ramst/Output/ramst_results.mat');
+ramst_results=load('../../simul/ramst/Output/ramst_results.mat');
 if max(abs(ramst_results.oo_.endo_simul(strmatch('k',ramst_results.M_.endo_names,'exact'),1:end-M_.maximum_lead)-oo_.endo_simul(strmatch('k',M_.endo_names,'exact'),1:end-M_.maximum_lead)))>1e-10
     error('Solution of forward part of the model not correct')
 end
diff --git a/tests/dsge_base2.mod b/tests/dsge_base2.mod
deleted file mode 100644
index a4a7c4ad4a884b3bcd818a428798473398d48c83..0000000000000000000000000000000000000000
--- a/tests/dsge_base2.mod
+++ /dev/null
@@ -1,36 +0,0 @@
-// This file deals with the resolution and estimation of a basic DSGE model with
-//employment for comparison with the benchmark in Gauss which solves with
-//the same particular filter but global methodology.
-//
-// January 2010
-
-var k A c l i y;
-varexo e_a;
-
-parameters alp bet tet tau delt rho ;
-alp = 0.4;
-bet = 0.99;
-tet = 0.357 ;
-tau = 50 ;
-delt = 0.02;
-rho = 0.95;
-
-model;
-c = ((1 - alp)*tet/(1-tet))*A*(1-l)*((k(-1)/l)^alp);
-y = A*(k(-1)^alp)*(l^(1-alp)) ;
-i = y-c ;
-k = (1-delt)*k(-1) + i ;
-log(A) = rho*log(A(-1)) + e_a ;
-(((c^(tet))*((1-l)^(1-tet)))^(1-tau))/c - bet*((((c(+1)^(tet))*((1-l(+1))^(1-tet)))^(1-tau))/c(+1))*(1 -delt+alp*(A(1)*(k^alp)*(l(1)^(1-alp)))/k)=0 ;
-end;
-
-shocks;
-var e_a; stderr 0.035;
-end;
-
-steady;
-
-stoch_simul;
-
-save dsge_base2.mat oo_ M_ options_;
-close all, clc;
diff --git a/tests/example1_with_tags.mod b/tests/equation_tags/example1_with_tags.mod
similarity index 100%
rename from tests/example1_with_tags.mod
rename to tests/equation_tags/example1_with_tags.mod
diff --git a/tests/ramst_static_tag.mod b/tests/equation_tags/ramst_static_tag.mod
similarity index 100%
rename from tests/ramst_static_tag.mod
rename to tests/equation_tags/ramst_static_tag.mod
diff --git a/tests/ramst_static_tag_block.mod b/tests/equation_tags/ramst_static_tag_block.mod
similarity index 100%
rename from tests/ramst_static_tag_block.mod
rename to tests/equation_tags/ramst_static_tag_block.mod
diff --git a/tests/estim_param_in_shock_value_xfail.mod b/tests/estimation/estim_param_in_shock_value_xfail.mod
similarity index 100%
rename from tests/estim_param_in_shock_value_xfail.mod
rename to tests/estimation/estim_param_in_shock_value_xfail.mod
diff --git a/tests/example1.mod b/tests/example1.mod
deleted file mode 100644
index 54b0ffa9c26b9e84af21ea4b932acb6a7778fb4c..0000000000000000000000000000000000000000
--- a/tests/example1.mod
+++ /dev/null
@@ -1,52 +0,0 @@
-// Example 1 from Collard's guide to Dynare
-var y, k, a, h, b;
-varexo e, u;
-
-verbatim;
-% I want these comments included in
-% example1.m 1999q1 1999y
-%
-var = 1;
-end;
-
-parameters beta, rho, alpha, delta, theta, psi, tau;
-
-alpha = 0.36;
-rho   = 0.95;
-tau   = 0.025;
-beta  = 0.99;
-delta = 0.025;
-psi   = 0;
-theta = 2.95;
-
-phi   = 0.1;
-
-model;
-[endogenous='c',name='law of motion of capital']
-c*theta*h^(1+psi)=(1-alpha)*y;
-k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
-    *(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
-y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
-k = exp(b)*(y-c)+(1-delta)*k(-1);
-a = rho*a(-1)+tau*b(-1) + e;
-b = tau*a(-1)+rho*b(-1) + u;
-end;
-
-initval;
-y = 1.08068253095672;
-c = 0.80359242014163;
-h = 0.29175631001732;
-k = 11.08360443260358;
-a = 0;
-b = 0;
-e = 0;
-u = 0;
-end;
-
-shocks;
-var e; stderr 0.009;
-var u; stderr 0.009;
-var e, u = phi*0.009*0.009;
-end;
-
-stoch_simul;
diff --git a/tests/+matlab/+namespace/y_k.m b/tests/first_order/+matlab/+namespace/y_k.m
similarity index 100%
rename from tests/+matlab/+namespace/y_k.m
rename to tests/first_order/+matlab/+namespace/y_k.m
diff --git a/tests/walsh.mod b/tests/first_order/walsh.mod
similarity index 98%
rename from tests/walsh.mod
rename to tests/first_order/walsh.mod
index fced66cca6603eb9be11e8177c0720562093adeb..0275d71aad67cab5fb5cdc1acc4c8485632fefd2 100644
--- a/tests/walsh.mod
+++ b/tests/first_order/walsh.mod
@@ -1,3 +1,5 @@
+//test solvers for decision rules as well as accessing matlab namespace from steady state file (see #1639)
+
 @#define Blocks = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15","16", "17", "18", "19", "20", "21", "22", "23", "24", "25","26", "27", "28", "29", "30", "31", "32", "33", "34", "35","36", "37", "38", "39", "40", "41", "42", "43", "44", "45","46", "47", "48", "49", "50", "51", "52", "53", "54", "55","56", "57", "58", "59", "60", "61", "62", "63", "64", "65","66", "67", "68", "69", "70", "71", "72", "73", "74", "75","76", "77", "78", "79", "80", "81", "82", "83", "84", "85","86", "87", "88", "89", "90", "91", "92", "93", "94", "95","96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115","116", "117", "118", "119", "120", "121", "122", "123", "124", "125","126", "127", "128", "129", "130", "131", "132", "133", "134", "135","136", "137", "138", "139", "140", "141", "142", "143", "144", "145","146", "147", "148", "149", "150", "151", "152", "153", "154", "155","156", "157", "158", "159", "160", "161", "162", "163", "164", "165","166", "167", "168", "169", "170", "171", "172", "173", "174", "175","176", "177", "178", "179", "180", "181", "182", "183", "184", "185","186", "187", "188", "189", "190", "191", "192", "193", "194", "195","196", "197", "198", "199", "200"]
 
 @#define blocks = Blocks[1:20]
diff --git a/tests/example1_varexo_det.mod b/tests/forecast/example1_varexo_det.mod
similarity index 100%
rename from tests/example1_varexo_det.mod
rename to tests/forecast/example1_varexo_det.mod
diff --git a/tests/log_transform/ramst.mod b/tests/log_transform/ramst.mod
index 01ce1514d36b1fed89082a8b50a238941d1c4a8c..a99501158729c3b7de0445e0baebfdb88d736d85 100644
--- a/tests/log_transform/ramst.mod
+++ b/tests/log_transform/ramst.mod
@@ -45,7 +45,7 @@ if max(abs(oo_.endo_simul(idx_log_c, :) - log(oo_.endo_simul(idx_c, :)))) > 1e-7
   error('Transformation not correctly performed')
 end
 
-S = load('../ramst/Output/ramst_results.mat');
+S = load('../simul/ramst/Output/ramst_results.mat');
 if max(abs(oo_.endo_simul(idx_c, :) - S.oo_.endo_simul(idx_c, :))) > 1e-7
   error('Result differs from non-transformed model')
 end
diff --git a/tests/model_diagnostics/example2_block_model_diag.mod b/tests/model_diagnostics/example2_block_model_diag.mod
new file mode 100644
index 0000000000000000000000000000000000000000..dcee082e1a018324fae8a101cd24257a43aa139c
--- /dev/null
+++ b/tests/model_diagnostics/example2_block_model_diag.mod
@@ -0,0 +1,63 @@
+//test singular Jacobian check with block decomposition
+
+/*
+ * Example 2 from F. Collard (2001): "Stochastic simulations with DYNARE:
+ * A practical guide" (see "guide.pdf" in the documentation directory).
+ */
+
+/*
+ * Copyright (C) 2001-2010 Dynare Team
+ *
+ * This file is part of Dynare.
+ *
+ * Dynare is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Dynare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+
+var y, c, k, a, h, b;
+varexo e, u;
+
+parameters beta, rho, alpha, delta, theta, psi, tau;
+
+alpha = 0.36;
+rho   = 1;
+tau   = 0;
+beta  = 0.99;
+delta = 0.025;
+psi   = 0;
+theta = 2.95;
+
+model(block);
+exp(c)*theta*exp(h)^(1+psi)=(1-alpha)*exp(y);
+exp(k) = beta*(((exp(b)*exp(c))/(exp(b(+1))*exp(c(+1))))
+         *(exp(b(+1))*alpha*exp(y(+1))+(1-delta)*exp(k)));
+exp(y) = exp(a)*(exp(k(-1))^alpha)*(exp(h)^(1-alpha));
+exp(k) = exp(b)*(exp(y)-exp(c))+(1-delta)*exp(k(-1));
+a = rho*a(-1)+tau*b(-1) + e;
+b = tau*a(-1)+rho*b(-1) + u;
+end;
+
+initval;
+y = 0.1;
+c = -0.2;
+h = -1.2;
+k =  2.4;
+a = 0;
+b = 0;
+e = 0;
+u = 0;
+end;
+
+steady;
+model_diagnostics;
\ No newline at end of file
diff --git a/tests/objectives/sgu_ex1.mat b/tests/objectives/sgu_ex1.mat
deleted file mode 100644
index 5f7a3b3dde42fbe9c399ee925b4df7a630f69b3b..0000000000000000000000000000000000000000
--- a/tests/objectives/sgu_ex1.mat
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:92631dd8caf649e29cb8d2626c2edeb70f74ee4aef6a3407ea2f0c96e062e878
-size 1368
diff --git a/tests/objectives/sgu_ex1.mod b/tests/objectives/sgu_ex1.mod
deleted file mode 100644
index 4ee09866a956a6652021f41aee6fde731cf90577..0000000000000000000000000000000000000000
--- a/tests/objectives/sgu_ex1.mod
+++ /dev/null
@@ -1,33 +0,0 @@
-periods 20000;
-var c k a;
-varexo e;
-parameters alpha beta delta gamma rho;
-
-beta = 0.95;
-delta = 1;
-alpha = 0.3;
-rho = 0;
-gamma = 2;
-
-model;
-exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha;
-exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta);
-a = rho * a(-1) + e;
-end;
-
-initval;
-k=0;
-c=0;
-a=0;
-e=0;
-end;
-
-Sigma_e_ = 1;
-
-stoch_simul(nomoments,irf=0,nocorr,ar=0);
-
-global dr_
-dr_obj_ = dr_;
-
-save sgu_ex1.mat dr_obj_;
-
diff --git a/tests/comments.mod b/tests/preprocessor_checks/comments.mod
similarity index 100%
rename from tests/comments.mod
rename to tests/preprocessor_checks/comments.mod
diff --git a/tests/example1_extra_exo_xfail.mod b/tests/preprocessor_checks/example1_extra_exo_xfail.mod
similarity index 100%
rename from tests/example1_extra_exo_xfail.mod
rename to tests/preprocessor_checks/example1_extra_exo_xfail.mod
diff --git a/tests/example1_mlv.mod b/tests/preprocessor_checks/example1_mlv.mod
similarity index 100%
rename from tests/example1_mlv.mod
rename to tests/preprocessor_checks/example1_mlv.mod
diff --git a/tests/example1_undeclared_vars_xfail.mod b/tests/preprocessor_checks/example1_undeclared_vars_xfail.mod
similarity index 100%
rename from tests/example1_undeclared_vars_xfail.mod
rename to tests/preprocessor_checks/example1_undeclared_vars_xfail.mod
diff --git a/tests/ramst_xfail.mod b/tests/preprocessor_checks/ramst_all_values_required_xfail.mod
similarity index 100%
rename from tests/ramst_xfail.mod
rename to tests/preprocessor_checks/ramst_all_values_required_xfail.mod
diff --git a/tests/ramst_model_edit.mod b/tests/preprocessor_checks/ramst_model_edit.mod
similarity index 95%
rename from tests/ramst_model_edit.mod
rename to tests/preprocessor_checks/ramst_model_edit.mod
index a5600d6e6b7778c9dfa101359db01745bf92a569..1bbfc96eca263a9b3cc240fe6fa72427436459ab 100644
--- a/tests/ramst_model_edit.mod
+++ b/tests/preprocessor_checks/ramst_model_edit.mod
@@ -56,7 +56,7 @@ end;
 perfect_foresight_setup(periods=200);
 perfect_foresight_solver;
 
-S = load('ramst/Output/ramst_results.mat');
+S = load('../simul/ramst/Output/ramst_results.mat');
 if any(size(oo_.endo_simul) ~= size(S.oo_.endo_simul)) || any(any(abs(oo_.endo_simul - S.oo_.endo_simul) > 1e-10))
   error('Model editing failure')
 end
diff --git a/tests/histval_det.mod b/tests/simul/histval_det.mod
similarity index 100%
rename from tests/histval_det.mod
rename to tests/simul/histval_det.mod
diff --git a/tests/predetermined_variables.mod b/tests/simul/predetermined_variables.mod
similarity index 100%
rename from tests/predetermined_variables.mod
rename to tests/simul/predetermined_variables.mod
diff --git a/tests/ramst.mod b/tests/simul/ramst.mod
similarity index 100%
rename from tests/ramst.mod
rename to tests/simul/ramst.mod
diff --git a/tests/ramst2.mod b/tests/simul/ramst2.mod
similarity index 100%
rename from tests/ramst2.mod
rename to tests/simul/ramst2.mod
diff --git a/tests/ramst_a.mod b/tests/simul/ramst_a.mod
similarity index 100%
rename from tests/ramst_a.mod
rename to tests/simul/ramst_a.mod
diff --git a/tests/ramst_mshocks.mod b/tests/simul/ramst_mshocks.mod
similarity index 100%
rename from tests/ramst_mshocks.mod
rename to tests/simul/ramst_mshocks.mod
diff --git a/tests/ramst_mshocks_vec.mod b/tests/simul/ramst_mshocks_vec.mod
similarity index 100%
rename from tests/ramst_mshocks_vec.mod
rename to tests/simul/ramst_mshocks_vec.mod
diff --git a/tests/ramst_vec.mod b/tests/simul/ramst_vec.mod
similarity index 100%
rename from tests/ramst_vec.mod
rename to tests/simul/ramst_vec.mod
diff --git a/tests/example1_abs_sign.mod b/tests/stat_functions/example1_abs_sign.mod
similarity index 100%
rename from tests/example1_abs_sign.mod
rename to tests/stat_functions/example1_abs_sign.mod
diff --git a/tests/ramst_normcdf_and_friends.inc b/tests/stat_functions/ramst_normcdf_and_friends.inc
similarity index 100%
rename from tests/ramst_normcdf_and_friends.inc
rename to tests/stat_functions/ramst_normcdf_and_friends.inc
diff --git a/tests/ramst_normcdf_and_friends_bytecode.mod b/tests/stat_functions/ramst_normcdf_and_friends_bytecode.mod
similarity index 100%
rename from tests/ramst_normcdf_and_friends_bytecode.mod
rename to tests/stat_functions/ramst_normcdf_and_friends_bytecode.mod
diff --git a/tests/ramst_normcdf_and_friends_mfile.mod b/tests/stat_functions/ramst_normcdf_and_friends_mfile.mod
similarity index 100%
rename from tests/ramst_normcdf_and_friends_mfile.mod
rename to tests/stat_functions/ramst_normcdf_and_friends_mfile.mod
diff --git a/tests/ramst_normcdf_and_friends_use_dll.mod b/tests/stat_functions/ramst_normcdf_and_friends_use_dll.mod
similarity index 100%
rename from tests/ramst_normcdf_and_friends_use_dll.mod
rename to tests/stat_functions/ramst_normcdf_and_friends_use_dll.mod
diff --git a/tests/fs2000_ssfile.mod b/tests/steady_state/fs2000_ssfile.mod
similarity index 100%
rename from tests/fs2000_ssfile.mod
rename to tests/steady_state/fs2000_ssfile.mod
diff --git a/tests/fs2000_ssfile_aux.m b/tests/steady_state/fs2000_ssfile_aux.m
similarity index 100%
rename from tests/fs2000_ssfile_aux.m
rename to tests/steady_state/fs2000_ssfile_aux.m
diff --git a/tests/example1_irf_shocks.mod b/tests/stochastic_simulations/example1_irf_shocks.mod
similarity index 100%
rename from tests/example1_irf_shocks.mod
rename to tests/stochastic_simulations/example1_irf_shocks.mod
diff --git a/tests/example1long.mod b/tests/stochastic_simulations/example1long.mod
similarity index 100%
rename from tests/example1long.mod
rename to tests/stochastic_simulations/example1long.mod
diff --git a/tests/example2.mod b/tests/stochastic_simulations/example2_simul_replic.mod
similarity index 100%
rename from tests/example2.mod
rename to tests/stochastic_simulations/example2_simul_replic.mod
diff --git a/tests/example2long.mod b/tests/stochastic_simulations/example2long.mod
similarity index 100%
rename from tests/example2long.mod
rename to tests/stochastic_simulations/example2long.mod
diff --git a/tests/example2long_use_dll.mod b/tests/stochastic_simulations/example2long_use_dll.mod
similarity index 100%
rename from tests/example2long_use_dll.mod
rename to tests/stochastic_simulations/example2long_use_dll.mod
diff --git a/tests/seeds.mod b/tests/stochastic_simulations/example_seeds.mod
similarity index 100%
rename from tests/seeds.mod
rename to tests/stochastic_simulations/example_seeds.mod
diff --git a/tests/histval_predetermined.mod b/tests/stochastic_simulations/histval_predetermined.mod
similarity index 98%
rename from tests/histval_predetermined.mod
rename to tests/stochastic_simulations/histval_predetermined.mod
index 51ac05cf8f5c436a7f8119e1d529b59692f216da..4bfdbc3e97cebfb97444d4519673de55ede8d7b0 100644
--- a/tests/histval_predetermined.mod
+++ b/tests/stochastic_simulations/histval_predetermined.mod
@@ -56,5 +56,4 @@ end;
 
 stoch_simul(nograph, periods = 200);
 
-forecast;
-
+forecast;
\ No newline at end of file
diff --git a/tests/histval_sto.mod b/tests/stochastic_simulations/histval_sto.mod
similarity index 100%
rename from tests/histval_sto.mod
rename to tests/stochastic_simulations/histval_sto.mod
diff --git a/tests/t_periods_a.mod b/tests/t_periods_a.mod
deleted file mode 100644
index 26a064d9ef24580607a624d89d29b4a068fbe07b..0000000000000000000000000000000000000000
--- a/tests/t_periods_a.mod
+++ /dev/null
@@ -1,37 +0,0 @@
-var c k;
-varexo x;
-
-parameters alph gam delt bet aa;
-alph=0.5;
-gam=0.5;
-delt=0.02;
-bet=0.05;
-aa=0.5;
-
-
-model;
-c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
-c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
-end;
-
-initval;
-x = 1;
-k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
-c = aa*k^alph-delt*k +1 ;
-end;
-
-steady;
-
-check;
-
-shocks;
-var x;
-periods 1;
-values 1.2;
-end;
-
-perfect_foresight_setup(periods=200);
-perfect_foresight_solver;
-
-rplot c;
-rplot k;
diff --git a/tests/t_sgu_ex1.mod b/tests/t_sgu_ex1.mod
deleted file mode 100644
index 87e270666659efa7c0651985a7cca3f020f8c546..0000000000000000000000000000000000000000
--- a/tests/t_sgu_ex1.mod
+++ /dev/null
@@ -1,37 +0,0 @@
-var c k a;
-varexo e;
-parameters alpha beta delta gamma rho;
-
-beta = 0.95;
-delta = 1;
-alpha = 0.3;
-rho = 0;
-gamma = 2;
-
-model;
-exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha;
-exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta);
-a = rho * a(-1) + e;
-end;
-
-initval;
-k=0;
-c=0;
-a=0;
-e=0;
-end;
-
-Sigma_e_ = 1;
-
-stoch_simul(nomoments,nocorr,ar=0,irf=0);
-
-global dr_
-load objectives/sgu_ex1;
-
-fataltest(oo_.dr.ghx,dr_obj_.ghx,1);
-fataltest(oo_.dr.ghu,dr_obj_.ghu,2);
-fataltest(oo_.dr.ghxx,dr_obj_.ghxx,3);
-fataltest(oo_.dr.ghxu,dr_obj_.ghxu,4);
-fataltest(oo_.dr.ghuu,dr_obj_.ghuu,5);
-
-disp('TESTS OK');