Clean up + adding tests

done for [AGPUSH-402](https://issues.jboss.org/browse/AGPUSH-402)