Test cases implementation, pep8 compatible and slight code modifications