Added unit test and eliminated 'dead' code