diff --git a/src/@x13/clean.m b/src/@x13/clean.m
index 9d87ad979d9ce1422fba48be2750bbd7452c5a9e..fc8ce6118c4e46947e9a416541d4f3a23ef6670f 100644
--- a/src/@x13/clean.m
+++ b/src/@x13/clean.m
@@ -1,4 +1,4 @@
-function clean(o)
+function clean(o) % --*-- Unitary tests --*--
 
 % Erase generated files if any.
 
@@ -20,4 +20,19 @@ function clean(o)
 if ~isempty(o.results)
     basename = o.results.name;
     delete(sprintf('%s.*', basename))
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ try
+%$     series = dseries(rand(100,1),'1999M1');
+%$     o = x13(series);
+%$     o.x11('save','(d11)');
+%$     o.run();
+%$     o.clean();
+%$     t(1) = true;
+%$ catch
+%$     t(1) = false;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/@x13/print.m b/src/@x13/print.m
index fa8952b83b7dcaa54cc625c0b10eee62d0bf43fe..b9d13c51779b4bac464919a1ca595db1c36a49ee 100644
--- a/src/@x13/print.m
+++ b/src/@x13/print.m
@@ -1,4 +1,4 @@
-function basename = print(o, basename)
+function basename = print(o, basename) % --*-- Unitary tests --*--
 
 % Prints spc file.
 
@@ -352,7 +352,7 @@ if ismember('x11regression', o.commands)
                     for i=1:length(conditionningvariables)
                         if ~ismember(conditionningvariables{i}, o.x.name)
                             fclose(fid);
-                            error('x13:x11regression: Variable %s is unkonwn', conditionningvariables{i})
+                            error('x13:x11regression: Variable %s is unknown', conditionningvariables{i})
                         end
                     end
                     % Select the data.
@@ -390,4 +390,35 @@ if ismember('x11regression', o.commands)
     fprintf(fid, '}\n\n');
 end
 
-fclose(fid);
\ No newline at end of file
+fclose(fid);
+
+%@test:1
+%$ try
+%$     series = dseries(rand(100,1),'1999M1');
+%$     o = x13(series);
+%$     o.x11('save','(d11)');
+%$     o.automdl('savelog','amd','mixed','no');
+%$     o.outlier('types','all','save','(fts)');
+%$     o.check('maxlag',24,'save','(acf pcf)');
+%$     o.estimate('save','(mdl est)');
+%$     o.forecast('maxlead',18,'probability',0.95,'save','(fct fvr)');
+%$     o.run(); % necessary to invoke alphanumeric "basename"
+%$     o.print();
+%$
+%$     text = fileread(sprintf('%s.spc',o.results.name));
+%$     comm = o.commands;
+%$
+%$     for i = 1:numel(comm)
+%$         ex(i,1) = ~isempty(strfind(text,[comm{i} ' {']));
+%$     end
+%$
+%$     if all(ex)
+%$         t(1) = true;
+%$         o.clean();
+%$     end
+%$ catch
+%$     t(1) = false;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/@x13/subsasgn.m b/src/@x13/subsasgn.m
index 3fe9956ed303eba330cdd6a81fc9e9b25eeb3f08..163c2dd33b3c806905a4026186e364773922532d 100644
--- a/src/@x13/subsasgn.m
+++ b/src/@x13/subsasgn.m
@@ -1,4 +1,4 @@
-function val = subsasgn(val, idx, rhs)
+function val = subsasgn(val, idx, rhs) % --*-- Unitary tests --*--
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -16,3 +16,33 @@ function val = subsasgn(val, idx, rhs)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 error('Members of x13 class are private')
+
+%@test:1
+%$ t = zeros(3,1);
+%$
+%$ y = dseries(rand(100,1),'1999M1');
+%$ o = x13(y);
+%$
+%$ try
+%$     o.commands = {'yes','no','maybe'};
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ try
+%$     o.results = 'Perverse string';
+%$     t(2) = false;
+%$ catch
+%$     t(2) = true;
+%$ end
+%$
+%$ try
+%$     o.y = dseries(rand(100,1));
+%$     t(3) = false;
+%$ catch
+%$     t(3) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/@x13/subsref.m b/src/@x13/subsref.m
index df687ff1b06b5bfa7f8c5231e028de1827a79c88..80466b1c8e223bf7ef051bbccd5afec424367866 100644
--- a/src/@x13/subsref.m
+++ b/src/@x13/subsref.m
@@ -1,4 +1,4 @@
-function o = subsref(o, S)
+function o = subsref(o, S) % --*-- Unitary tests --*--
 
 % Overloads the subsref method.
 
@@ -93,4 +93,47 @@ switch S(1).type
     end
   otherwise
     error('x13:: I do not understand what you are asking for!')
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ t = zeros(1,5);
+%$ o = x13();
+%$
+%$ try
+%$     o(arima);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ try
+%$     o.unicorn;
+%$     t(2) = false;
+%$ catch
+%$     t(2) = true;
+%$ end
+%$
+%$ try
+%$     o.x11('onearg','onevalue','twoargs');
+%$     t(3) = false;
+%$ catch
+%$     t(3) = true;
+%$ end
+%$
+%$ try
+%$     o.x11('unicorn','yes please');
+%$     o.x11.unicorn;
+%$     t(4) = false;
+%$ catch
+%$     t(4) = true;
+%$ end
+%$
+%$ try
+%$     o.print.unicorn;
+%$     t(5) = false;
+%$ catch
+%$     t(5) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/@x13/x13.m b/src/@x13/x13.m
index 98fc4422ebd83534532b3a85937cf25c554414b1..fe169c42500fdafbcdfe7a2216ae9dfe2d5dfab4 100644
--- a/src/@x13/x13.m
+++ b/src/@x13/x13.m
@@ -1,4 +1,4 @@
-classdef x13<handle
+classdef x13<handle % --*-- Unitary tests --*--
 
 % Class for X13 toolbox.
 
@@ -118,4 +118,42 @@ methods
     end
 end
 
-end
\ No newline at end of file
+end
+
+%@test:1
+%$
+%$ try
+%$     series = dseries(rand(100,2),'1999M1');
+%$     o = x13(series);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
+
+%@test:2
+%$ try
+%$     series = rand(100,2);
+%$     o = x13(series);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:2
+
+%@test:3
+%$ try
+%$     y = dseries(rand(100,1),'1999M1');
+%$     x = rand(100,2);
+%$     o = x13(y,x);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:3
\ No newline at end of file
diff --git a/src/utilities/x13/checkcommandcompatibility.m b/src/utilities/x13/checkcommandcompatibility.m
index 9359cddc821821ecb8e686c7c7f6261c8b53d183..a710383a8cce10f3e81ad51214cf0ca3dc7e7d77 100644
--- a/src/utilities/x13/checkcommandcompatibility.m
+++ b/src/utilities/x13/checkcommandcompatibility.m
@@ -1,4 +1,4 @@
-function checkcommandcompatibility(o, comm)
+function checkcommandcompatibility(o, comm) % --*-- Unitary tests --*--
 
 % Checks for compatibility of X13 commands.
 
@@ -20,7 +20,7 @@ function checkcommandcompatibility(o, comm)
 switch comm
   case 'arima'
     if ismember('automdl', o.commands)
-        error('x13:arima: ARIMA command is not compatible with AUTOMDL command!')               
+        error('x13:arima: ARIMA command is not compatible with AUTOMDL command!')
     elseif ismember('pickmdl', o.commands)
         error('x13:arima: ARIMA command is not compatible with PICKMDL command!')
     end
@@ -34,7 +34,31 @@ switch comm
     if ismember('arima', o.commands)
         error('x13:pickmdl: PICKMDL command is not compatible with ARIMA command!')
     elseif ismember('automdl', o.commands)
-        error('x13:pickmdl: PICKMDL command is not compatible with AUTOMDL command!')              
-    end                          
+        error('x13:pickmdl: PICKMDL command is not compatible with AUTOMDL command!')
+    end
   otherwise
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ t = zeros(2,1);
+%$
+%$ series = dseries(rand(100,1),'1999M1');
+%$ o = x13(series);
+%$ o.arima('save','(d11)');
+%$
+%$ try
+%$     o.automdl('savelog','amd');
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ try
+%$     o.pickmdl('savelog','amd');
+%$     t(2) = false;
+%$ catch
+%$     t(2) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/utilities/x13/checkoptioncompatibility.m b/src/utilities/x13/checkoptioncompatibility.m
index e405ae2ca26818c869db737c1a60dfa406e2ddb5..541ccdaa236b64b6a36c593dbc5633aa70075e64 100644
--- a/src/utilities/x13/checkoptioncompatibility.m
+++ b/src/utilities/x13/checkoptioncompatibility.m
@@ -1,4 +1,4 @@
-function checkoptioncompatibility(o)
+function checkoptioncompatibility(o) % --*-- Unitary tests --*--
 
 % Checks for compatibility of options in different X13 commands.
 
@@ -34,5 +34,36 @@ if ~isempty(o.estimate.file)
         error('Command AUTOMDL not compatible with ESTIMATE.file option!');
     elseif ismember('pickmdl',o.commands)
         error('Command PICKMDL not compatible with ESTIMATE.file option!');
-    end    
-end
\ No newline at end of file
+    end
+end
+
+%@test:1
+%$ t = zeros(3,1);
+%$
+%$ series = dseries(rand(100,1),'1999M1');
+%$ o = x13(series);
+%$ o.estimate('file','test');
+%$
+%$ try
+%$     o.arima('model','(1 0 1)');
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ try
+%$     o.pickmdl('savelog','amd');
+%$     t(2) = false;
+%$ catch
+%$     t(2) = true;
+%$ end
+%$
+%$ try
+%$     o.regression('b',0.9);
+%$     t(3) = false;
+%$ catch
+%$     t(3) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/utilities/x13/isoption.m b/src/utilities/x13/isoption.m
index e63d44ae121bdd20b4113283b10ae1a0bbf7ef53..6c3bef5a542d19ef5ad27abb39b91ab732bdab11 100644
--- a/src/utilities/x13/isoption.m
+++ b/src/utilities/x13/isoption.m
@@ -1,4 +1,4 @@
-function b = isoption(command, option)
+function b = isoption(command, option) % --*-- Unitary tests --*--
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -78,3 +78,21 @@ switch command
   otherwise
     error('x13:isoption: Unknown block!')
 end
+
+%@test:1
+%$ try
+%$     b = isoption('unicorn','horse sounds');
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
+
+%@test:2
+%$ b = isoption('arima','ar');
+%$ c = ~isoption('arima','unicorn');
+%$ t = [b;c];
+%$ T = all(t);
+%@eof:2
\ No newline at end of file
diff --git a/src/utilities/x13/printoption.m b/src/utilities/x13/printoption.m
index 4e65e0db75a12f058bf33d0f26e23e2f79e835df..d33cfbe19cd906d81f70336ccfd439fefa3c1f8b 100644
--- a/src/utilities/x13/printoption.m
+++ b/src/utilities/x13/printoption.m
@@ -1,4 +1,4 @@
-function printoption(fid, optname, optvalue)
+function printoption(fid, optname, optvalue) % --*-- Unitary tests --*--
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -41,4 +41,21 @@ elseif isreal(optvalue)
             error('This option value type is not implemented!');
         end
     end
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ fid = fopen('test.spc', 'w');
+%$
+%$ try
+%$     series = dseries(rand(100,1),'1999M1');
+%$     o = x13(series);
+%$     o.x11('save','(d11)');
+%$     optnames = fieldnames(o.x11);
+%$     printoption(fid,'mode',o.x11.mode);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/utilities/x13/printspan.m b/src/utilities/x13/printspan.m
index aceef2754413b28bafbc29e9dfce31f647fb3624..fe1ba46e088a48a7e12ab575f962f856b4f16ef6 100644
--- a/src/utilities/x13/printspan.m
+++ b/src/utilities/x13/printspan.m
@@ -1,4 +1,4 @@
-function printspan(fid, period1, period2)
+function printspan(fid, period1, period2) % --*-- Unitary tests --*--
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -37,4 +37,46 @@ switch period1.freq
     fprintf(fid, ' span = (%i,%i)\n', period1.year, period2.year);
   otherwise
     error('x13:regression: This is a bug! Please contact the authors.')
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ try
+%$     per1 = dates(52,1996,1);
+%$     per2 = dates(52,1996,2);
+%$     fid = fopen('test.spc', 'w');
+%$     printstart(fid,per1,per2);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
+
+%@test:2
+%$ try
+%$     per1 = dates(52,1996,1);
+%$     per2 = dates(52,1994,2);
+%$     fid = fopen('test.spc', 'w');
+%$     printstart(fid,per1,per2);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:2
+
+%@test:3
+%$ try
+%$     per1 = dates(4,1996,1);
+%$     per2 = dates(52,1996,2);
+%$     fid = fopen('test.spc', 'w');
+%$     printstart(fid,per1,per2);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:3
\ No newline at end of file
diff --git a/src/utilities/x13/printstart.m b/src/utilities/x13/printstart.m
index 43bfea56fc54fc78c333934f88bc0c77ae416aea..1d803e5be61d73e1c291561cf7e6cc87c04461c2 100644
--- a/src/utilities/x13/printstart.m
+++ b/src/utilities/x13/printstart.m
@@ -1,4 +1,4 @@
-function printstart(fid, period)
+function printstart(fid, period) % --*-- Unitary tests --*--
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -29,4 +29,17 @@ switch period.freq
     fprintf(fid, ' start = %i\n', period.year);
   otherwise
     error('x13:regression: This is a bug! Please contact the authors.')
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ try
+%$     per = dates(52,1996,1);
+%$     fid = fopen('test.spc', 'w');
+%$     printstart(fid,per);
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
diff --git a/src/utilities/x13/setdefaultmember.m b/src/utilities/x13/setdefaultmember.m
index a266a0f698582c5787c4d440a9272a434d1db08d..356480bc538c7833409635a05e7581938260fa96 100644
--- a/src/utilities/x13/setdefaultmember.m
+++ b/src/utilities/x13/setdefaultmember.m
@@ -1,4 +1,4 @@
-function s = setdefaultmember(name)
+function s = setdefaultmember(name) % --*-- Unitary tests --*--
 
 % Sets members of X13 object to default values (empty).
 
@@ -82,3 +82,14 @@ switch name
   otherwise
     error('x13:setdefaultmember: Unknown member!')
 end
+
+%@test:1
+%$ try
+%$     setdefaultmember('PyotrIlychTchaikowsky');
+%$     t(1) = false;
+%$ catch
+%$     t(1) = true;
+%$ end
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file