Fixed minor bugs.
Added some unit tests in loader.