Add macros and refactor tests
Split functionalities into files