Fix rake task and add test for it

Change-Id: Idc7564816b430066672a624301390937e55d3c81
Reviewed-on: http://gerrit.causes.com/45246
Tested-by: jenkins <jenkins@brigade.com>
Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>