Fixed code style, improved tests a bit