Modernizing + tests

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