Tests and Refactor for client-side app