Addressed review comments, added tests and reworked a bit