Rewrite test code for ert framework.
Add test-deferred entry in Makefile