Refactor groovy to java

Coverts and fixes nginx tests