added tests and fixed a bug with cost comparison