Modernizing + tests

Tests are imported from one of my projects, coding style may not match yours, but it does the job.