Set up testing, refactor code to best practices