Fixed #33 and added regression test