Fixed code style, remover unused codes, added test