add configs for prod and test, refactor handler code a bit