Fixed miscillaneous bugs, and write unit-test suite using EcomDev_PHPUnit