Fixed minor bugs found on unit testing.